WP7 Bing map in popup
I'm working on a WP7 demo app and have gotten my popup working with static resources wich I earlier had problems with. Now when this is out of the way i got a new bug wich regards my use of Bing Maps.
When using bing maps in my default WP7 Silverlight pages (panorama or regual) the maps show up fine, but when using a bing map in my static resource layout the map itself is just showing up black.
Controls around the map such as the navigation pane with zoom and map modes display fine and the bing map logo and distance reference line also show up fine but the map images is just plain black (transparent since the background of my popup is black).
Anyone who encountered this before?
I came up on post where this problem occured in the default silverlight pages (some signed assemblies bug) so I tried their fix with unsigned assemblies but then my WP7 app did not start.
*Edit My popup resource XAML code looks like this.
<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>
no code needed for displaying a map, this xaml works in a standard silverlight WP7 page but not when used in resources like this. When used like this the map image/content will be missing and transparent.
Sorry to be a party pooper, but you might be affected by this nugget of truth:
http://blogs.claritycon.com/blogs/kevin_marshall/
Content in a popup is not hardware accelerated. If you try to animate stuff in a popup, it will be slow. If you need to mimic popup like functionality, consider re-templating the PhoneApplicationFrame to wrap the contentpresenter in a grid and place a contentpresenter below it to act as a placeholder for a fake popup. You can then write a popup manager to insert whatever child you previously had in a popup into the content presenter/fake popup. This allows you to have better perf on the content in the popup and you can have smoother animations for sliding / flipping the popup into place.
Adding the popup to the Visual Tree (any child control of your page) should solve the problem.
精彩评论