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
close icon

Using Last item in Listview to add new item to the list in runtime

I am using SfListview in my Xamarin.Forms app. I am using left swipe, right swipe and drag and drop features in the listview. I wish to remove swipe and drag and drop for last item alone. I am using last item as Add Item row, so that user can add new item to the list dynamically at runtime.  But I wish to remove swipe and reordering feature which doesn't make sense for last item. 


Is that possible???

1 Reply

VR Vigneshkumar Ramasamy Syncfusion Team December 24, 2018 08:50 AM UTC

Hi Subha,  
   
Thanks for using Syncfusion product.  
  
We have checked reported query from our side. We would like to know you can skip swiping in SwipeStarted event and dragging in ItemDragging event by using specific index for which action is needed to be skipped or use can even load your add icon in FooterTemplate which will not swipe or drag when dragging or swiping option enabled for listview. We have already mentioned about this in our UG documentation, please refer UG from below link.  
  
  
  
  
  
  
namespace ListViewSample  
{  
    public partial class MainPage : ContentPage  
    {  
        public MainPage()  
        {  
            listView.SwipeStarted += ListView_SwipeStarted;  
            listView.ItemDragging += ListView_ItemDragging;  
        }  
  
        private void ListView_ItemDragging(object sender, Syncfusion.ListView.XForms.ItemDraggingEventArgs e)  
        {  
            int lastItemIndex = listView.DataSource.DisplayItems.Count-1;  
            if (e.Action == DragAction.Start && e.NewIndex == lastItemIndex)  
                e.Cancel = true;  
        }  
  
        private void ListView_SwipeStarted(object sender, Syncfusion.ListView.XForms.SwipeStartedEventArgs e)  
        {  
            int lastItemIndex = listView.DataSource.DisplayItems.Count-1;  
  
            if (e.ItemIndex == lastItemIndex)  
                e.Cancel = true;  
        }  
    }  
}  
  
  
   
  
Regards,  
Vigneshkumar R 


Loader.
Live Chat Icon For mobile
Up arrow icon