Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142137 | Jan 21,2019 11:36 PM UTC | Jan 24,2019 11:54 AM UTC | Xamarin.Forms | 5 |
![]() |
Tags: SfListView |
namespace TabView
{
public class Behavior :Behavior<SfListView>
{
SfListView ListView;
ViewModel ViewModel;
protected override void OnAttachedTo(SfListView listView)
{
ListView = listView;
ViewModel = new ViewModel();
ViewModel = listView.BindingContext as ViewModel;
ListView.ItemDragging += ListView_ItemDragging;
ListView.DataSource.LiveDataUpdateMode = Syncfusion.DataSource.LiveDataUpdateMode.AllowDataShaping;
base.OnAttachedTo(listView);
}
private async void ListView_ItemDragging(object sender, ItemDraggingEventArgs e)
{
if (e.Action == DragAction.Drop)
{
if (e.OldIndex < e.NewIndex)
{
await Task.Delay(100);
ChangeData(e);
}
}
}
private void ChangeData(ItemDraggingEventArgs e)
{
ViewModel.ToDoList.MoveTo(e.OldIndex, e.NewIndex);
var position = e.Position.Y;
var itemSize = 0;
for (int i = 0; i < ViewModel.ToDoList.Count; i++)
{
(ViewModel.ToDoList[i] as ToDoItem).OrderPosition = position + itemSize;
itemSize += 60;
}
}
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.