WP7 Bing地图弹出窗口

时间:2010-10-20 07:08:10

标签: silverlight popup windows-phone-7 bing-maps

我正在开发一个WP7演示应用程序并让我的弹出窗口与static resources一起工作,我之前遇到过问题。现在,当我遇到一个关于我对Bing Maps的使用的新bug时,我已经不在了。

在我的默认WP7 Silverlight页面(全景或版本)中使用bing贴图时,地图显示正常,但在我的静态资源布局中使用bing贴图时,地图本身只显示黑色。

地图周围的控件(如带缩放和地图模式的导航窗格)显示正常,bing地图徽标和距离参考线也显示正常,但地图图像只是纯黑色(透明,因为我的弹出窗口的背景是黑色的)。

之前遇到此事的人?

我出现在默认的Silverlight页面中出现此问题的帖子(一些已签名的程序集错误)所以我尝试使用未签名的程序集进行修复,但后来我的WP7应用程序没有启动。

*编辑 我的弹出资源XAML代码如下所示。

<ResourceDictionary xmlns:my="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Skanetrafiken.Controls;assembly=Skanetrafiken.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    >
    <Style TargetType="local:MapRouteDialog">
        <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/>
        <Setter Property="Width" Value="480"/>
        <Setter Property="Height" Value="800"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MapRouteDialog">
                    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}" Margin="0, 0, 0, 0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <!--TitlePanel contains the name of the application and page title-->
                        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,30,0,40">
                            <TextBlock x:Name="DialogTitle" Text="MY DIALOG TITLE" Style="{StaticResource PhoneTextNormalStyle}"/>
                        </StackPanel>
                        <my:Map x:Name="RouteMap" Grid.Row="1" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  NavigationVisibility="Visible">
                            <Button x:Name="ButtonZoomIn" HorizontalAlignment="Left" VerticalAlignment="Top" Height="56" Width="56" Margin="8,180,0,0" BorderBrush="{x:Null}" Foreground="{x:Null}">
                                <Button.Background>
                                    <ImageBrush ImageSource="/Skanetrafiken.Controls;component/images/Zoom_In.png" />
                                </Button.Background>
                            </Button>
                            <Button x:Name="ButtonZoomOut" HorizontalAlignment="Left" VerticalAlignment="Top" Height="56" Width="56" Margin="8,260,0,0" BorderBrush="{x:Null}" Foreground="{x:Null}">
                                <Button.Background>
                                    <ImageBrush ImageSource="/Skanetrafiken.Controls;component/images/Zoom_Out.png" />
                                </Button.Background>
                            </Button>
                            <my:MapLayer Name="RouteLines"></my:MapLayer>
                            <my:MapItemsControl Name="PushPins"/>
                        </my:Map>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

显示地图不需要代码,此xaml在标准的Silverlight WP7页面中工作,但在此类资源中使用时则不行。如果这样使用,地图图像/内容将会丢失且透明。

2 个答案:

答案 0 :(得分:1)

很抱歉成为派对大佬,但你可能会受到这个真相的影响:

http://blogs.claritycon.com/blogs/kevin_marshall/

  

弹出窗口中的内容不是硬件   加快。如果您尝试动画   弹出窗口中的东西,它会很慢。如果   你需要模仿像弹出窗口一样   功能,考虑重新模板化   包装的PhoneApplicationFrame   网格中的contentpresenter并放置一个   在它下面的contentpresenter充当   占位符为假弹出窗口。您可以   然后编写一个弹出管理器来插入   无论你以前有过什么样的孩子   弹出内容演示者/假   弹出。这可以让你拥有更好的   对弹出窗口中的内容进行穿孔   你可以拥有更流畅的动画   滑动/翻转弹出窗口   的地方。

答案 1 :(得分:0)

将弹出窗口添加到Visual Tree(页面的任何子控件)应该可以解决问题。