簡體   English   中英

windows phone 8地圖未在用戶控件中顯示

[英]windows phone 8 map not displaying in user control

我想在我的應用程序中實現“附加位置”功能。 我決定創建一個用戶控件並將我的地圖放入其中,然后在單擊某個按鈕時,我會在全屏彈出/自定義消息框中顯示此控件。

問題是一切正常,只是地圖根本沒有顯示; 我可以檢索我的位置,放置圖釘,縮放似乎工作(盡管事實上我沒有看到任何東西!)。

更奇怪的是,復制並粘貼到手機應用程序頁面的相同代碼工作正常,並顯示地圖。 我不明白,這是我不知道的限制嗎?

這是我的代碼:

    <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>

您是否嘗試以編程方式添加地圖?

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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM