This project has moved and is read-only. For the latest updates, please go here.

ZoomLevel TwoWay Binding causes erratic behavior

Oct 29, 2013 at 5:43 PM
Edited Oct 29, 2013 at 5:55 PM
I'm experiencing some odd behavior if I bind to ZoomLevel with a two way data binding. When I scroll the mouse wheel to zoom in, it zooms in and then snaps back out partially. If I change the binding mode to OneWay, it works as expected. Using XamlMapControl version 1.6.

Steps to reproduce:
  1. Modify WpfApplication\MainWindow.xaml.cs adding a property:
    public double Zoom { get; set; }
  2. Modify WpfApplication\MainWindow.xaml changing the ZoomLevel to
    ZoomLevel="{Binding Path=Zoom, Mode=TwoWay, RelativeSource={RelativeSource Self}}"
Robert Graves

TwoWay binding to TargetZoomLevel works well.
Oct 30, 2013 at 9:27 AM
Edited Oct 30, 2013 at 10:37 AM
The behaviour is indeed odd if you take into account that your binding doesn't work. You've added the Zoom property to class MainWindow, but in the binding declaration you specify the Map object as binding source (by RelativeSource Self). You should have seen a binding error message like
System.Windows.Data Error: 40 : BindingExpression path error: 'Zoom' property not found on 'object' ''Map' (Name='map')'. BindingExpression:Path=Zoom; DataItem='Map' (Name='map'); target element is 'Map' (Name='map'); target property is 'ZoomLevel' (type 'Double')
Anyway, looking again into how the interaction between ZoomLevel, Center and Heading and the corresponding Target properties and their animations are handled in MapBase makes me feel that a little change is necessary. I'll come up with a new version soon.
Oct 30, 2013 at 2:33 PM
Quite right, sorry about the binding. I was trying to hack a simple example to reproduce the behavior without including a ViewModel. Binding to the TargetZoomLevel is sufficient for my needs.

Oct 30, 2013 at 11:32 PM
Ok, fixed this in new version 1.6.1.
Oct 31, 2013 at 8:47 PM
Thanks, that did the trick.