I need to be able to temporarily disable the panning and zooming of my RadCartesianChart but I cannot see how to do it.
I've got a plot of a profile that I want the user to be able to zoom horizontally and pan. I accomplish this via a ChartPanAndZoomBehavior:
<tk:RadCartesianChart.Behaviors>
<tk:ChartPanAndZoomBehavior ZoomMode="Horizontal"
PanMode="Horizontal"
DragMode="Pan"
/>
This has been working fine for a while now. I can pinch zoom as I want
But I also have some annotations on the chart that I needed to move with code-behind with Mouse and Touch Handlers, so I wrote handlers for MouseEvents (LeftButtonDown, MouseMove, LeftButtonUp) in which I handle moving my annotations. It works fine. In each handler, I mark the event as "Handled" to prevent it from bubbling up to the Chart.
This also has been working fine for a while. The user can drag the annotations and slide them across the profile and so the chart does not pan while I'm dragging my annotations, which is what I want. For example,here's the MouseMove handler.
private void RegionHandle_OnMouseMove(object sender, MouseEventArgs args)
{
if (!(sender is CartesianCustomAnnotation ann))
return;
if (!ann.IsMouseCaptured)
return;
// (Call my annotation manipulation code here...)
args.Handled = true; // Prevent chart from handling this.
}
Unfortunately, I cannot achieve the same thing with touch handlers. I wrote event handlers for ManipulationStarting, ManipulationStarted, ManipulationDelta and ManipulationCompleted. In each one I mark the event as "Handled" but it doesn't matter. The chart still pans while I am dragging my annotations. It is very confusing.
private void RegionHandle_OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
if (!(sender is CartesianCustomAnnotation ann))
return;
// (Call my annotation manipulation code here...)
args.Handled = true; // Prevent chart from handling this.
}
It appears there is no such thing as PreviewXXXX events for Manipulation events so I cannot use that route to intercept the touch handlers.
My next attempt at a fix came when I saw that the ChartPanAndZoomBehavior is a Dependency object and its ZoomMode, PanMode, and DragMode properties are DependencyProperties. So it should be valid to bind them to properties on my control and then just dynamically change them to ChartPanZoomMode.None and ChartDragMode.None in the handlers themselves, right? Nope. Does not work. I get a runtime exception claiming that "ChartPanZoomMode.None is not a valid value for PanMode" (which makes no sense to me).
So how can I selectively prevent the chart from panning when I want?
So how can I prevent the chart from handling touch events when I want and enable it otherwise?
-Joe
(p.s.: I cannot use your Format Code Block" functionality. The editor window always appears at top of the web page and it is obscured by the banner on the page with the "Telerik" menu, "Get a Free Trial" button, etc. I've tried this in two browsers, Edge and Chrome. I'll attach an image to this post to show what I mean..)