How do I get an event or notification when the user double-clicks to Zoom to fit on the chart?
Best regards
Jonas
- Jonas asked 11 years ago
- You must login to post comments
I guess you could derive a custom class from ZoomExtentsModifier and override OnModifierDoubleClick, e.g.
public class NotifyZoomExtentsModifier : ZoomExtentsModifier { public event EventHandler<EventArgs> OnUserZoomExtents; public override void OnModifierDoubleClick(ModifierMouseArgs e) { // Before ZoomExtents operation base.OnModifierDoubleClick(e); // After ZoomExtents operation RaiseOnUserZoomExtents(); } private void RaiseOnUserZoomExtents() { var handler = OnUserZoomExtents; if (handler != null) { handler(this, EventArgs.Empty); } } }
It makes for slightly messy code but it does demonstrate how you can override the ZoomExtentsModifier’s default behaviour to fire an event when the user double-clicks on the chart (and zooms extents).
Using the Expression Blend Interactivity extensions you could get this event to call a method in your ViewModel e.g. in MVVM.
Or, using some messaging library like the one in MVVM-Lite or an EventAggregator you could separate the publish/subscribe, thereby making it possible to notify some classes (e.g. a custom viewport manager, or other code) that the user did a zoom to extents.
- Andrew Burnett-Thompson answered 11 years ago
-
Excellent, solved my issue. Regards Jonas
- You must login to post comments
Please login first to submit.