Hi,
I have a XamDataChart inside a MainWindow scroll Viewer and the scrollViewer implements below to scroll the contents with Mouse Scroll.
private void OnPreviewMouseWheel (object sender, MouseWheelEventArgs e){ScrollViewer scrollView = (ScrollViewer) sender;scrollView.ScrollToVerticalOffset (scrollView.VerticalOffset - e.Delta);e.Handled = true;}
The issue is when cursor comes on XamDataChart while Mouse Scroll, I want chart should zoom in/zoom out as it works on Mouse scroll but this is not happening.
When I remove the above code, I can see chartzoom in/zoom out on Mouse scroll, but window contents are not scrolling.
I have set HorizontalZoomable and VerticalZoomable for chart to true.
Any comments?
Thanks,
Preeti
Hello Preeti,
I have been investigating this behavior you are reporting, and by marking e.Handled = true in your OnPreviewMouseWheel event handler for your ScrollViewer in this case, you will essentially be preventing the mouse-wheel event from being handled in the XamDataChart. This will effectively prevent the mouse-wheel zoom operations from happening.
Is there a particular reason that you are handling this PreviewMouseWheel event on the ScrollViewer and marking it handled?
Please let me know if you have any other questions or concerns on this matter.
Hello,
Yes...My window contains different UserControl which includes chart.
without e.handled=true, I am not able to keep the cursor anywhere on window and scroll up and down. I want this behavior with the scrollViewer.
But I also want that when while scrolling the cursor comes to chart or when I click on the chart, the chart should zoom. If I click outside the chart, window content should scroll.
Does that clarify the problem?