GestureSample
GestureSample copied to clipboard
ListView detect LongPress having SelectionMode="None"
I want to detect a Tap and a LongPress on a Listview item having the property ListView.SelectionMode set to "None".
The builtin ListView ItemTappedEventArgs provide an Item property, so that I can figure out the Item which was tapped. Unforunately your LongPressEventArgs does not provide this information, so that I only can rely on the SelectedItem property of the ListView. This does not work with ListView.SelectionMode="None".
If I am using your ViewCell and catch the Tap and LongPress, I can use the BindingContext of the sender to find out which Item was affected. But: the light grey flash animation when tapping the cell does not appear anymore. So the user does not have a feedback that the cell was hit.
I am looking for a way to either get the Viewcell animated when tapping it or finding out the long pressed item within your ListView_LongPressing event handler.
The tap Animation works on ios, but not on android.
That the ListView
provides only information about the ListView
itself and not its cells is by design.
For the missing animation I opened a bug in Xamarin.Forms in 2015!! @kingces95 and @pauldipietro added something in 2017, but otherwise the bug was ignored.
We could create an issue on https://github.com/xamarin/Xamarin.Forms/issues too, but then we should first test if the same happens with a CollectionView
. It is very likely and they will most probably be more inclined to look at it if the bug happens in their shiny new control.
This is a Xamarin.Android bug which is open for 9 years now. I can't do anything about it, so I'm closing it.