Here is the posted bug link: https://github.com/syncfusion/maui-demos/issues/46
Swiping is not working at in
Hi Divyesh Bhatt,
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.Code snippet:
|
#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> |
Please let us know if you have any queries.
Regards,
Suthi Yuvaraj.