Search code examples
androidxamarin.androidandroid-nestedscrollviewoxyplot

How to zoom/pan in OxyPlot.PlotView inside NestedScrollView without scrolling?


In my Android app made with Xamarin.Android I have a chart that uses OxyPlot.Android. The chart is a PlotView and is inside a NestedScrollView. The chart has pan and zoom enabled, but when I try to pan or zoom, the NestedScrollView also scrolls.

How do I prevent the NestedScrollView from scrolling while I touch the PlotView?


Solution

  • I added these event handlers to the plotview's model

    plotView.Model.TouchStarted += (sender, e) =>
    {
        if (plotView.Parent != null)
            plotView.Parent.RequestDisallowInterceptTouchEvent(true);
    };
    
    plotView.Model.TouchCompleted += (sender, e) =>
    {
        if (plotView.Parent != null)
            plotView.Parent.RequestDisallowInterceptTouchEvent(false);
    };