![](/img/trans.png)
[英]Binding Pushpins in ObservableCollection to Bing Maps Control WP7
[英]Twoway binding causes strange behaviour in maps control for wp7
我正在使用地图控件开发Windows Phone应用程序。 地图控件将其center和zoomlevel属性绑定到视图模型上的两个属性。
地图控件位于与应用程序主页分开的页面上。 每次用户移动到地图时,页面都会绑定到视图模型。 这个视图模型是一个单例(总是相同的实例)。
第一次移动到地图时,可以在地图上导航正常,但是当我返回并再次导航到地图时,导航会有些反弹,就像被推回到初始位置一样。 若要查看此行为,请执行以下操作:
主页仅包含一个导航到地图页面的按钮,如下所示:
<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#
有人知道如何解决此问题吗?
谢谢!
我看不出这是怎么回事? 除非您向后导航(因此不设置DataContext),否则Bing Maps将始终从全局视图到中心位置进行“弹跳”动画。 控件就是这样工作的,因此您无能为力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.