In your MainWindow code, create a public property using open access for access, something like this:
private double _mapZoom; public double MapZoom //I assume that ZoomLevel is of type double, if not use the correct type { get { return _mapZoom; } set { _mapZoom = value; OnPropertyChanged("MapZoom"); } }
You will need to implement the INotifyPropertyChanged interface in your MainWindow (there are a million examples around the world, no need to delve into this here).
Then attach your ZoomLevel to the MapZoom property as follows:
<map:Map Name="map" ZoomLevel="{Binding RelativeSource={RelativeSource Self}, Path=MapZoom}, Mode=TwoWay"/>
For this to work, the DataContext of the window must be the window itself, you need one line in the Window constructor:
public MainWindow() { InitializeComponent(); this.DataContext = this;
You need the second window to call the main window, so you can create a static property to return the current instance to mainwindow:
private static MainWindow _instance; public static MainWindow Instance { get { if (_instance == null) _instance = new MainWindow(); else _instance = this; return _instance; } }
Now you will have MainWindow exposing a public property that is tied to map scaling.
So, in the second window, create a property that points to this instance of the main window:
public MainWindow Main { get { return MainWindow.Instance; }
Finally, you can bind the scaling of the second map to the public MapZoom property, which is a member of Main:
<map:Map Name="map2" ZoomLevel="{{Binding RelativeSource={RelativeSource Self}, Path=Main.MapZoom}, Mode=TwoWay"}">
In this binding, "Main" refers to an instance of MainWindow through the public property window2 (set this .DataContext = this; in window2 too) and gain access to the .MapZoom property.
By default, all objects you create in XAML are private, so you must explicitly publish them with public properties using get / set accessors to make them accessible from the outside.
Let me know if this works, I have not created a code testing application. Hello!