synchronize viewports

Oct 18, 2010 at 11:44 AM


I have several isolinegraphs in a collection, and I am looking to synchronize the viewport state of each of these graphs (i.e. panning, zooming, etc.), since I am comparing between these graphs. For example, if I zoom into one graph, I'd like to keep the same zoom  (transform) for all the graphs.

Anyone done anything like this before?


Oct 18, 2010 at 5:20 PM

You will need to TwoWay bind to the ViewBoundary. Then add a PropertyChanged event to the Viewport of the Chart plotter to catch d3 mouse events.

ViewBoundary = new DataRect(Viewport.Visible.XMin, Viewport.Visible.YMin, Viewport.Visible.Width, Viewport.Visible.Height);

Oct 20, 2010 at 7:02 AM


Is there a property ViewBoundary? I couldn't find it.

It seems to me that if I could TwoWay bind to the Visible property on the Viewport2D , that would do the trick. Then I don't even need to catch mouse events- I can just check whenever the "ViewBoundary" (bound) changes.

But Visible isn't a dependency property....

can you elaborate a bit on which object you think I should bind to?


Oct 20, 2010 at 8:41 AM

Have you seen the discussion "IS there any evnt which gets fired when zooming or panning?" (

You can just use the viewports propertychanged event and set Chart1.Viewport.Visible = Chart2.Viewport.Visible (and Chart2.Viewport.Visible = Chart1.Viewport.Visible in another handler).

Oct 20, 2010 at 8:56 AM


Because I´m using the  MVVM pattern ( :( ) I need to expose Viewport.Visible in the XAML somehow and bind it. Otherwise I have no access to it from code.

Any ideas ? (other than abandoning MVVM?)

Oct 20, 2010 at 9:44 AM

You could create a class the inherits from ChartPlotter and implements the dependency property you are after.  This class could monitor propertychanged on the Visible property and update its dependency property as appropriate.

Oct 20, 2010 at 12:34 PM

I took your suggestion to inherit from ChartPlotter. I exposed a dependency property of type DataRect. I caught changes from the plotter by adding a handler for the ViewportPropertychanged event, which sets the dependency property.

Then I bind TwoWay to this property, and catch the property changed events to propagate the change to the other graphs.

thanks for your help....