SwipeGestures on a ViewCell in Android don't work and they break ContextActiions
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.RemoveProductCommand}" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True"/>
</ViewCell.ContextActions>
<ViewCell.View>
<Frame BackgroundColor="LightGray" Padding="1.5" HasShadow="False" CornerRadius="0">
<Frame.GestureRecognizers>
<SwipeGestureRecognizer Direction="Up" Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.MoveProductUpList}" CommandParameter="{Binding .}"/>
<SwipeGestureRecognizer Direction="Down" Command="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.MoveProductDownList}" CommandParameter="{Binding .}"/>
</Frame.GestureRecognizers>
<Grid Padding="5,8,5,8" BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Text="{Binding ID}" FontSize="Small" FontAttributes="Bold" TextColor="{Binding Source={x:Reference CPMobileOrderPage}, Path=BindingContext.DefaultPageDetailColor}" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center"/>
</Grid>
</Frame>
</ViewCell.View>
</ViewCell>
I have a Page where I have a switch and a Listview with items in. If I swipe the items with the switch enabled I can move them around. This works great on IOS. The SwipeGestureRecognizers are attached to the Frame inside the ViewCell.
Android the SwipeGestureRecognizer doesn't seem to work. It also seems to break the ContextActions and the binding for SelectedItem.
Android Support Library Version: 27.0.2
Affected Devices:
Galaxy S9+
I'm able to run your reproduction but I'm not entirely clear what your actual and expected behaviors are. When you say "move them around" what exactly do you mean? I'm able to move them with the switch thrown either way on iOS and neither on Android. So that is different but before digging in I'd like to know what you expect. A video would be helpful. Or if you could reduce the reproduction further. Maybe start with a blank project and add the minimum code necessary to demonstrate the problem.
What I meant was as you described. On IOS I can swipe up and down on a viewcell arranging items in a list (using the SwipeGestureRecognizer's commands bound to two methods in the viewmodel which move items up and down the list). On Android I can't the items stay static. Ill create a new project and try to replicate with minimum code.
Attached a new repro.
If you run the app you will get a listview. Swipe up on any item they should move up the list. Swipe down they should move down.
Android this doesn't happen. The context actions in android also don't work when there is a SwipeGestureRecognizer attached to anything in the viewcell. IOS swipe right and left you get the delete option. Android hold pressing an item usually you get the delete option at the top.
I'm experiencing the same issue. If I use SwipeGestureRecognizer on a ContentPage, if I have ScrollView or ListView inside that page (with only vertical scrolling behavior), left and right swipes are not detected only on Android device. Emulator works fine, iOS both the device and the simulator are also OK.
@bojanmisic can you elaborate on your ScrollView use case over here?
https://github.com/xamarin/Xamarin.Forms/issues/4552
I have a repro attached to that issue where I'm able to swipe in a ScrollView
If you can modify that repro? Or elaborate so we can reproduce that would be really helpful
I have the same problem.
I have a Listview inside a Stcklayout. when i use SwipeGestureRecognizer on the stacklayout its leftswipe and rightswipe doesn't work on Android , but that is working fine on iOS and UWp
Please update and resolve bug asap in android platform.
Any update on the issue, when it will be fixed ?
Why was this close? It has not been resolve.
Any updates on this?
Any updates on this?
Any updates on this? Still happening at XF 4.6.0.847 just on Android.
Most helpful comment
Any updates on this?