Forum Xamarin Xamarin.Forms

How to ignore the tapped of an overlapping element

JoyPeterJoyPeter Member ✭✭

I have two components one red and one pink, the pink is superimposing the red component.
the red component has a TapGestureRecognizer. I would like to know if it is possible to ignore the Tapped of the pink component,
in other words, when tapping the pink component, tap the red component. I don't know if I was clear

Image

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 1

    Is the red component a subview of pink component? If so, the pink component's tag gesture event will not be trigger when clicking the red component. Because the subview's priority is higer.

    <StackLayou BackgroundColor="Pink">
        <StackLayout.GestureRecognizers>
            <TapGestureRecognizer Tapped="PinkTapGestureRecognizer_Tapped"/>
        </StackLayout.GestureRecognizers>
    
        <StackLayout HeightRequest="200" BackgroundColor="Red">
            <StackLayout.GestureRecognizers>
                <TapGestureRecognizer Tapped="RedTapGestureRecognizer_Tapped"/>
            </StackLayout.GestureRecognizers>
        </StackLayout>
    
    </StackLayout>
    

Sign In or Register to comment.