我正在使用地图控件开发Windows手机应用程序。地图控件将其中心及其zoomlevel属性绑定到viewmodel上的两个属性。
地图控件位于与应用程序主页分开的页面上。每次用户移动到地图时,页面都会绑定到视图模型。这个视图模型是一个单例(总是相同的实例)。
我第一次移动到地图上导航时工作正常,但当我返回并再次导航到地图时,导航会有某种反弹,就像它被推回到其初始位置一样。 要查看此行为,请执行以下操作:
主页只包含一个导航到地图页面的按钮,如下所示:
<phone:PhoneApplicationPage
x:Class="MapTester.Map"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True"
DataContext="{Binding Path=MapViewModel, Source={StaticResource ViewModelLocator}}">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<maps:Map Center="{Binding Center, Mode=TwoWay}"
ZoomLevel="{Binding ZoomLevel,Mode=TwoWay}"
ZoomBarVisibility="Visible"
CredentialsProvider=""
ScaleVisibility="Visible"></maps:Map>
</Grid>
</phone:PhoneApplicationPage>
MapViewModel在ViewModelLocator上定义。我创建了一个解决方案来证明问题。您可以在此处下载https://skydrive.live.com/?cid=25374d9051083633&sc=documents&id=25374D9051083633%21344#
有人知道如何解决这个问题吗?
谢谢!
答案 0 :(得分:0)
我不明白这里有什么问题?除非您向后导航(因此不设置DataContext),否则Bing Maps将始终从全局视图到中心位置执行“反弹”动画。这就是控制的工作方式,所以你无能为力。