Articles in this section
Category / Section

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

1 min read

SfListView 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

 

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