每次属性更改时,Bing地图缩放级别都不会更新

时间:2011-05-22 16:55:19

标签: c# windows-phone-7 bing-maps

我有以下用于MS Bing Maps控件的xaml。 ZoomLevel绑定到ViewModel上名为“ZoomLevel”的属性。

<Microsoft_Phone_Controls_Maps:Map x:Name="routeMap"
                                   ZoomLevel="{Binding ZoomLevel}"
                                   Center="{Binding CurrentMapCenterPoint, Mode=TwoWay}"
                                   AnimationLevel="UserInput"
                                   HorizontalContentAlignment="Stretch"
                                   VerticalContentAlignment="Stretch">

现在首次显示地图时,缩放级别是正确的 - 可以从ViewModel设置,但是当用户更改分辨率然后进行另一次搜索并且ViewModel中的ZoomLevel属性发生更改时,它不会更新视图中的控件 - 旧的缩放级别仍在使用中。

为什么在渲染Bing地图控件后无法从ViewModel更改ZoomLevel的任何想法?

1 个答案:

答案 0 :(得分:2)

答案是为ZoomLevel属性双向绑定:

<Microsoft_Phone_Controls_Maps:Map x:Name="routeMap"
                                   ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}"
                                   Center="{Binding CurrentMapCenterPoint, Mode=TwoWay}"
                                   AnimationLevel="UserInput"
                                   HorizontalContentAlignment="Stretch"
                                   VerticalContentAlignment="Stretch">