Pre loader

How to get an Event on ZoomExtents

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

How do I get an event or notification when the user double-clicks to Zoom to fit on the chart?

Best regards
Jonas

  • You must to post comments
0
0

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.

  • Jonas
    Excellent, solved my issue. Regards Jonas
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies