Prevent propagation of swipe gestures onto parent controls in .NET MAUI?

  Kiến thức lập trình

Is there a way to prevent the propagation of swipe gestures from a control onto its parent control in .NET MAUI?

For this project I’m using a DXRangeSlider within a TabView. Both are free MAUI controls (at the time of writing) created by DevExpress. Nonetheless, any swipable control that is defined as content for the tab view, causes this issue.

When TabView.SwipeEnabled = True you can swipe left or right on the tab content to navigate to the previous or next tab in the sequence. When any of the tab contents contain swipable controls, or controls with swipe gesture recognizers, you cannot swipe these controls without calling the tab swipe action.

I’d like the TabView to ignore my swipe gesture when the swipe gesture is targeting a child control.

Is there any way to achieve this?

The XAML setup is nothing too complicated:

<dxcontrols:TabView>
    <dxcontrols:TabViewItem>
        ...
    </dxcontrols:TabViewItem>
    <!-- Parent swipable control: -->
    <dxcontrols:TabViewItem>
        ...
        <!-- Child swipable control: -->
        <dxeditors:DXRangeSlider/>
        ...
    </dxcontrols:TabViewItem>
    <dxcontrols:TabViewItem>
        ...
    </dxcontrols:TabViewItem>
</dxcontrols:TabView>

I believe the same issue would exist when using a MAUI Slider or any control with swipe gesture recognizers within a CarouselView that has swipe enabled. Haven’t tested this.

LEAVE A COMMENT