Coder Social home page Coder Social logo

Comments (1)

SuthiYuvaraj avatar SuthiYuvaraj commented on July 17, 2024

We have checked your requirement , we would like to let you know , we would like to inform you that within the Android platform, touch events are not relayed to the parent view when a child view contains gesture recognizers, as this is standard behavior within the framework. Hence we modified sample with customview, which have gesture and passes the touch to the parent item , Please have look at the sample , Added the customview inside the ItemTemplate , here you can use the GestureRegonizer instead of command in local:ContactCard , Please have a look at the sample and let us know if you have any concerns.

CustomClass.cs

#if ANDROID
    public class CustomContentView : ContentView, ITapGestureListener,IDoubleTapGestureListener,ILongPressGestureListener,ITouchListener
#else
    public class CustomContentView : ContentView
#endif
    {
        public CustomContentView()
        {
#if ANDROID
            this.AddGestureListener(this);
            this.AddTouchListener(this);
#endif
        }
 
        // Invoke SfListView's ItemTapped , ItemDoubleTapped and ItemLongPress events through ContentView gestures since,
        // touch won't passes to parent view in Android platform when child view has gesture recognizers.
        void ITapGestureListener.OnTap(TapEventArgs e)
        {
            var parent = this.GetParent(this);
            if (parent is ListViewItem)
            {
                (parent as ListViewItem).OnTap(e);
            }
        }
 
        void ITouchListener.OnTouch(Syncfusion.Maui.Core.Internals.PointerEventArgs e)
        {
           
            var parent = this.GetParent(this);
            if (parent is ListViewItem)
            {
                (parent as ListViewItem).OnTouch(e);
            }
        }
 
        void IDoubleTapGestureListener.OnDoubleTap(TapEventArgs e)
        {
            var parent = this.GetParent(this);
            if (parent is ListViewItem)
            {
                (parent as ListViewItem).OnDoubleTap(e);
            }
        }
 
        void ILongPressGestureListener.OnLongPress(LongPressEventArgs e)
        {
            var parent = this.GetParent(this);
            if (parent is ListViewItem)
            {
                (parent as ListViewItem).OnLongPress(e);
            }
       }
 
        internal object GetParent(object currentView)
        {
            while (currentView != null && currentView.GetType() != typeof(ListViewItem))
            {
                return this.GetParent((currentView as Element).Parent);
            }
 
            return currentView;
        }
    }

In XAML

<syncfusion:SfListView x:Name="listView" Grid.Row="1" ScrollBarVisibility="Never" 
ItemSize="60"
AllowSwiping="True"
BackgroundColor="#FFE8E8EC"
ItemsSource="{Binding ToDoList}"
DragStartMode="OnDragIndicator,OnHold"
ItemTapped="listView_ItemTapped"
SelectionMode="None">

<syncfusion:SfListView.ItemTemplate>
<DataTemplate>
<local:CustomContentView>
<local:CustomContentView.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</local:CustomContentView.GestureRecognizers>
<Grid x:Name="rootGrid" Padding="10" BackgroundColor="Beige">
<Label  Text="{Binding Name}"/>
</Grid>
</local:CustomContentView>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>

SfListViewGesture.zip

from maui-demos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.