How to trigger and dismiss swipe action in sfListView via on click event ?

I want to show swipe action in sflistview while clicking on a button.

3 Replies

VR Vigneshkumar Ramasamy Syncfusion Team July 23, 2018 11:55 AM UTC

Hi Sairam,  
  
Thanks for contacting Syncfusion support.  
  
We have checked the reported query `Swipe action in SfListView while clicking on Button` from our end. We would like to know that we have achieved your requirement in our sample. As of now we don’t have direct support to swipe using button, so we handled swipe manually by passing InitialPosition toProcessTouchMove method. Here, we have passed 0th  children in our sample, you can pass any item in the list by passing items index. We have attached the sample for your reference, please let us know whether the sample meets your requirement.  
  
You can download the sample from below link.  
  
  
  private void button_Clicked(object sender, EventArgs e)  
        {  
            var btn = sender as Button;  
            Device.BeginInvokeOnMainThread(async () =>  
           {  
               VisualContainer visualContainer = listView.GetVisualContainer();  
               int count = visualContainer.Children.Count();  
               Random r = new Random();  
               int index = r.Next(0, count);  
               var swipeController = listView.GetType().GetRuntimeProperties().FirstOrDefault(ptyname => ptyname.Name == "SwipeController").GetValue(listView);  
               var item = visualContainer.Children[0];  
               if (item is SwipeView)  
                   return;  
               var swipeItem = item.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name =="ListViewItemInfo").GetValue(item);  
               if (swipeItem == null)  
                   return;  
               var iteminfo = swipeItem as ListViewItemInfoBase;  
               var position = iteminfo.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name =="InitialPosition");  
               position.SetValue(iteminfo, 10);  
               var swipeStarted = swipeController.GetType().GetRuntimeMethods().FirstOrDefault(methd => methd.Name == "ProcessTouchMove");  
               swipeStarted.Invoke(swipeController, new object[] { iteminfo, new Point(120, 10) });  
               await Task.Delay(1000);  
           });  
        }  
  
            //You can call this method to reset the swiped item   
            //listView.ResetSwipe();     
  
  
You can also reset swiped item by calling ResetSwipe  method.  
  
Please let us know if you require any further assistance.  
  
Regards,  
Vigneshkumar R 
  



LI Liva July 24, 2018 02:34 PM UTC

Thanks for an update. How to implemented this swipe click button using viewmodel. Then one more requirement it possible to swipe full cell.


VR Vigneshkumar Ramasamy Syncfusion Team July 25, 2018 01:28 PM UTC

Hi Sairam,  
  
Sorry for the inconvenience.  
  
We have checked the reported query from our end. We regret to inform you that we are facing complexity in architectural level, while implementing your requirement in ViewModel. So, we will provide Helper method to achieve your requirement in any of our upcoming release. 
 
Regards,  
Vigneshkumar R 


Loader.
Up arrow icon