Articles in this section
Category / Section

How to swipe the item indefinitely and layout back on specified position when swipe end?

1 min read

Xamarin.Forms ListView allows you to load multiple views in both left and right swipe by customizing the LeftSwipeTemplate and RightSwipeTemplate properties. You can refer the following UG documentation link for more reference.

UG Link: https://help.syncfusion.com/xamarin/sflistview/swiping#multiple-views

 

To swipe an item indefinitely, you need to set the SwipeOffset property by considering the width/height of the SfListView with Orientation accordingly as like following code example.

C#

ListView.PropertyChanged += ListView_PropertyChanged;
 
private void ListView_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
  if (e.PropertyName == "Width" && ListView.Orientation == Orientation.Vertical && ListView.SwipeOffset != ListView.Width)
     ListView.SwipeOffset = ListView.Width;
  else if (e.PropertyName == "Height" && ListView.Orientation == Orientation.Horizontal && ListView.SwipeOffset != ListView.Height)
     ListView.SwipeOffset = ListView.Height;
}

 

You can layout the swiping item to desired offset value for both right and left swipe accordingly once the swipe action is completed in the SwipeEnded event using SwipeOffset argument in the SwipeEndedEventArgs as like following code example.

C#

ListView.SwipeEnded += ListView_SwipeEnded;
 
private void ListView_SwipeEnded(object sender, SwipeEndedEventArgs e)
{
   if (e.SwipeDirection == SwipeDirection.Right)
       e.SwipeOffset = 80;
   else if (e.SwipeDirection == SwipeDirection.Left)
       e.SwipeOffset = 120;
}

 

Now run the application to render the following output.

Left swipe item

Swiping indefinitely

Swipe ended



 

Right swipe item

Swiping indefinitely

Swipe ended



 

 

Sample Link: ListView_CustomSwipe

 

Conclusion

I hope you enjoyed learning about how to swipe the item indefinitely and layout back on specified position when swipe end.

You can refer to our Xamarin.Forms ListView feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied