Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamrin Forms : Swipe to delete(gesture) in ListView

I want to implement the swipe to delete functionality in Xamrin Forms, for which i have tried the following.

  1. Wrote a custom renderer for the list view and in the "OnElementChanged" of the renderer am able to access the binded command to the "CustomListView" and am able to add this command to the Swipe Gesture as added below.

       swipeGestureRecognizer = new UISwipeGestureRecognizer (() => {
            if (command == null) {
                Console.WriteLine ("No command set");
                return;}
    
            command.Execute (null);
        });
    

However i am having trouble in accessing the specific row(swiped row), so that i could make a button visible/hidden on the swiped row in the list view. Please could you recommend a way to implement the same?

like image 834
balu Avatar asked Sep 17 '14 09:09

balu


1 Answers

Swipe to delete is now built into Xamarin Froms ListViews using a ContextAction. Here is the most basic tutorial of how to do it. It is very easy to implement.

http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/listview/

like image 179
Caitlin Taggart Avatar answered Sep 22 '22 22:09

Caitlin Taggart