SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.