3
votes

I want to implement an 'attach location' feature in my application. I've decided to create a user control and put my map in it, then upon a certain button click I show this control in a full screen popup/custom message box.

The problem is that everything works fine except that the map is simply not being displayed; I can retrieve my location, put pushpins, zooming seems working(despite the fact that I'm not seeing anything!).

Whats more weird is that the same code copied and pasted to a phone application page works fine and map appears. I don't understand, is this a limitation that I don't know of?

Here's my code:

    <UserControl
       .....
        xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
        mc:Ignorable="d"
     ....
    >
<Grid x:Name="LayoutRoot" Background="Black">

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <maps:Map Mode="AerialWithLabels"  
                    Grid.Row="0" 
                    Height="300" 
                    HorizontalAlignment="Left" 
                    Name="map1" VerticalAlignment="Top" 
                    Width="460" Margin="-12,0,0,0">
            </maps:Map>
            <Button Content="share location" 
                    Name="btn_SendLocation" 
                    IsEnabled="False" 
                    Grid.Row="1" 
                    Click="Button_Click_1"/>
            <ListBox Grid.Row="2" 
                     Name="lst_NearBy" 
                     DataContext="{Binding Location}" 
                     Tap="lst_NearBy_Tap">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,5">
                            <TextBlock Text="{Binding mName}" Style="{StaticResource PhoneTextLargeStyle}"/>
                            <TextBlock Text="{Binding mVicinity}" Margin="10,0,0,0" Foreground="Gray"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>
1
Try setting up the Width and Height of the UserControl.Rajeev Nair

1 Answers

0
votes

Did you try adding the map programatically?

private Constructor()
{
    Map my_map = new Map();
    my_map.Name= "map1";
    my_map.mode = "AerialWithLabels";
    my_map.Height = 300;
    my_map.Margin = new Thickness(-12,0,0,0);
    my_map.VerticalAlignment = System.Windows.VerticalAlignment.Top;
    my_map.HorizontalAlignment= System.Windows.HorizontalAlignment.Left;
    ContentPanel.Children.Add(my_map);
}