Xamarin.forms: [XForms] If parent and child element have gestures , Then child element gesture only fired. Parent element gesture not fired

Created on 21 Jun 2019  路  4Comments  路  Source: xamarin/Xamarin.Forms

Description

If parent and child element have gestures , Then child element gesture only fired. Parent element gesture not fired for all platforms (UWP, Android and IOS)

<local:GridExt x:Name="ListView" BackgroundColor="AntiqueWhite">
        <local:GridExt.GestureRecognizers>
            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
        </local:GridExt.GestureRecognizers>
        <ScrollView>
            <StackLayout>
                <local:ContentViewExt x:Name="ListViewItemGrid">
                    <local:ContentViewExt.GestureRecognizers>
                        <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1"/>
                    </local:ContentViewExt.GestureRecognizers>
                    <Label x:Name="Item" FontSize="Large" Text="ItemTemplate" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HeightRequest="100" BackgroundColor="Gray"/>
                </local:ContentViewExt>
            </StackLayout>
        </ScrollView>
    </local:GridExt>
public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            //DisplayAlert("ListView", "ListViewTappedFired", "Ok");
            Debug.WriteLine("ListViewTappedFired");
        }

        private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
        {
            //DisplayAlert("Item", "ItemTappedFired", "Ok");
            Debug.WriteLine("ItemTappedFired");
        }
    }

    public partial class GridExt : Grid
    {

    }

    public partial class ContentViewExt : ContentView
    {

    }

Steps to Reproduce

  1. Run the Sample
  2. Tap the Label
  3. Note: ContentView gesture only fired, Grid gesture not fired.

Expected Behavior

I need child gesture fired and parent gesture fired. Give me any workaround.
Note : I am find the android workaround, Thats worked for me. But I need uwp and ios also

Android render file

public class GridExtRenderer : ViewRenderer<GridExt, Views.View>
    {
        public GridExtRenderer(Context context) : base(context)
        {
        }

        public override bool OnInterceptTouchEvent(Views.MotionEvent ev)
        {
            OnTouchEvent(ev);
            return base.OnInterceptTouchEvent(ev);
        }
    }

Actual Behavior

If child element have gesture then parent gesture not fired.

Basic Information

  • Version with issue: latest 4.0
  • Last known good version: No
  • IDE: Visual Studio 2017
  • Nuget Packages: latest XF version 4.0
  • Affected Devices: All

Reproduction Link

https://www.syncfusion.com/downloads/support/directtrac/general/ze/TouchTest876899649

gestures 馃枛 7 help wanted partner bug up-for-grabs

All 4 comments

@Yuvaraj-007 Thank you for the report. We're aware that our gestures conflict, and we're planning to improve gesture management in the future.

@PureWeen Did we ever put together that spec for gesture orchestration? We should get one published ASAP. Thanks!

Unluckily, Swipe Gestures are fired both for child and parent view. So this is heavily inconsistent and sounds like something very basic with gestures.

For example if I put a CollectionView in a StackLayout with a SwipeGestureRecognizer, the recognizer will fire along with the collectionview scroll, while normal should be that CollectionView "blocks" the Stacklayout's recognizer. Or at least there should be an option to do this.

Hi @balazserd,

My requirement is I need to write the touch gesture recognizer for both child and parent view..i am also doing the custom view create idea to do this.. So your idea not worked for me. I need a support from your basic controla not like custom view of swipe gesture.
Thanks and Regards,
Yuvaraj C

This wasn't a suggestion, this was just to clarify your bug is not consistent. SwipeGestures work the other way, and they're also bugged.

Was this page helpful?
0 / 5 - 0 ratings