Hello,
Welcome to Microsoft Q&A
When you reorder items in ListView
control, you need to drag and drop an item. Dragging an item in ListView
will be mapped to a Remove
action of ObservableCollection
, and dropping an item in ListView
will be mapped to a Add
action of ObservableCollection
. Therefore, an Remove
and Add
actions emit in pairs when you reorder items by using drag-and-drop interation.
If you want to listen the reorder event completion, you could add the following if
statement to check if the CollectionChanged
event handler is called the second time(CollectionChanged
event handler completes the Add
action) which marks the completion of the reorder.
You could check the code as a sample:
private ObservableCollection<string> collections;
private int count;
private bool flag = false;
public MainPage()
{
this.InitializeComponent();
collections = new ObservableCollection<string>();
collections.Add("cgedg");
collections.Add("detyh");
collections.Add("edgde");
collections.Add("asdfg");
collections.Add("bdedg");
collections.CollectionChanged += Collections_CollectionChanged;
count = collections.Count;
}
private void Collections_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if(count-1==collections.Count)
{
flag = true;
}
if(count==collections.Count&&flag)
{
//The reorder completes.
flag = false;
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.