We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to swipe an item programatically in Xamarin.Forms ListView

Platform: Xamarin.Forms |
Control: SfListView |
Published Date: December 17, 2018 |
Last Revised Date: February 27, 2020

You can swipe an item programmatically by using the SwipeItem method of Xamarin.Forms SfListView.




        <Grid HeightRequest="50">
            <Button x:Name="RightSwipe" Text="Right Swipe Button" />
            <Button x:Name="LeftSwipe" Text="Left Swipe Button" Grid.Column="1"/>
        <listView:SfListView x:Name="listView" ItemSize="70" SelectionMode="Single" AllowSwiping="True"
    ItemSpacing="0,0,5,0" >
                            <Grid BackgroundColor="SlateBlue"  HorizontalOptions="Fill" VerticalOptions="Fill">
                                <Label Text="Left Swipe Template" TextColor="White" VerticalOptions="Center" HorizontalOptions="Center"/>
                            <Grid BackgroundColor="SlateBlue" HorizontalOptions="Fill" VerticalOptions="Fill">
                                <Label Text="Right Swipe Template" TextColor="White" VerticalOptions="Center"/>




You need to pass the item to be swiped and SwipeOffset as parameter in the SwipeItem method. The SwipeOffset value should be positive for LeftSwiping of ListViewItem.


private void LeftSwipeButton_Clicked(object sender, EventArgs e)
    ListView.SwipeItem(viewModel.contactsinfo[1], 200);


The SwipeOffset value should be negative for RightSwiping of ListViewItem.


private void RightSwipeButton_Clicked(object sender, EventArgs e)
    ListView.SwipeItem(viewModel.contactsinfo[1], -150);




LeftSwipe image for Xamarin.Forms ListView   RightSwipe image for Xamarin.Forms ListView


Download sample in GitHub

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile