Adding PanGestureRecognizer in ListView Item

JaraJara PHMember ✭✭

In Xamarin.Forms I have a ListView which I could remove the items by swiping left or right. Adding a PanGestureRecognizer works, I can swipe the items left or right but the problem is when I deploy it to iOS, I cannot scroll vertically anymore but in Android, it was working.

I am using Xamarin.Forms pre5

Below is my actual implementation of the ListView and the PanGestureRecognizer

Answers

  • JaraJara PHMember ✭✭

    I read about the https://developer.xamarin.com/guides/xamarin-forms/user-interface/listview/interactivity/ but it's not what I am looking for because there are more gestures that I will be implementing in a listviewitem.

  • EsamSherifEsamSherif EGUniversity ✭✭

    as for iOS native gestures there are two aspects
    1. if using UISwipeGestureRecognizer, you can listen for specific direction only (ex: left, right, top, bottom) so if swipe is vertical your UIView wouldnt listen for it and the Listview/UITableView will scroll instead.
    2. if using UIPanGestureRecognizer, there is a work around in this stackoverflow question, basically same idea of not listening to vertical swipe

    Anyway... I don't know which one Xamarin.Forms uses for PanGestureRecognizer, but im sure they are listening to every swipe direction.

    Conclusion:
    If you need your specific behavior then you need to implement your own swipe recognizer using CustomRenderer.
    Or maybe Xamarin would improve their PanGestureRecognizer implementation.

    Question:
    I've tried it before and it didnt work well on android either.. my swipe had to be exactly only horizontal, other wise the ListView would scroll instead of my PanGestureRecognizer behavior.... are you sure Android is working perfect?

  • JaraJara PHMember ✭✭

    @EsamSherif regarding your question, yes swiping listview items horizontally using PanGesture works on Android and I can still scroll vertically.

  • MichelMoorlagMichelMoorlag USMember ✭✭

    @jaysonragasa. I have the same Issue here. I have added a PanGestureRecognizer to listen to horizontal swipes to delete some cell content. In Android I still can scroll my listview but in iOS I can't.
    Did you find a solution for this?

  • MichelMoorlagMichelMoorlag USMember ✭✭

    I think this is a bug in XF, so I issued a bug report for this.

Sign In or Register to comment.