必应地图缩放级别不会在每次属性更改时更新

本文关键字:属性 更新 地图 缩放 | 更新日期: 2023-09-27 17:57:08

我有以下用于MS Bing Maps控件的xaml。 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 属性发生更改时,它不会更新视图中的控件 - 旧的缩放级别仍在使用。

为什么在呈现必应地图控件后无法从视图模型更改缩放级别?

必应地图缩放级别不会在每次属性更改时更新

答案是使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">