How to bind maximum and minimum zoom levels in Bing Maps Silverlight

谁说胖子不能爱 提交于 2019-12-06 00:05:52

You won't be able to bind like this because Mode is not a dependency property nor is MapMode a dependency object. Neither are any of the other properties in the chain nor do they implement INotifyPropertyChanged. So binding these is pretty much doomed.

You will need some code. It might be that the Map's ModeChanged event fires when the range is changed, in which case you can update the the Min/Max at the point.

Failing that use one of the view changed events like TargetViewChanged or ViewChangeEnd.

As stated elsewhere, you can't do this via binding, at least not using the current API.

The following code will do the trick. Pop it just after your InitializeComponent(); statement.

Action updateSliderRange = () =>
    {
        _slider.Minimum = _map.Mode.ZoomRange.From;
        _slider.Maximum = _map.Mode.ZoomRange.To;
    };
_map.ModeChanged += delegate { updateSliderRange(); };
_map.TargetViewChanged += delegate { updateSliderRange(); };
updateSliderRange();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!