Hi Johannes,
Thank you for contacting Syncfusion support.
We have analyzed your query “To reorder itemsSource collection based on the
visual order after drag and drop” and you can achieve your requirement by
handling RowDragDropController.Dropped event as like below code snippet
AssociatedObject.RowDragDropController.Dropped
+= sfGrid_Dropped; private void
sfGrid_Dropped(object sender, TreeGridRowDroppedEventArgs e) { if (e.DropPosition !=
DropPosition.None) { //Get Dragging nodes
ObservableCollection<TreeNode> draggingRecords = e.Data.GetData("Nodes") as
ObservableCollection<TreeNode>; if (draggingRecords == null) return; ViewModel model =
AssociatedObject.DataContext as ViewModel; //Use Batch update to avoid data operations in SfTreeGrid during
records removing and inserting
AssociatedObject.BeginInit(); //Removes the dragging nodes from the underlying collection foreach (TreeNode item in draggingRecords) {
model.Employees.Remove(item.Item as EmployeeInfo); } //Find the target node index after removing the nodes int targetIndex = model.Employees.IndexOf(e.TargetNode.Item
as EmployeeInfo); int insertionIndex = e.DropPosition
== DropPosition.DropAbove ? targetIndex : targetIndex + 1; insertionIndex =
insertionIndex < 0 ? 0 : insertionIndex; //Insert dragging nodes to the target position for (int i = draggingRecords.Count - 1; i >= 0; i--) {
model.Employees.Insert(insertionIndex, draggingRecords[i].Item as EmployeeInfo); }
AssociatedObject.EndInit(); } } |
Please find sample for the same from below link and let us
know if this helps you.
http://www.syncfusion.com/downloads/support/forum/140723/ze/DragAndDropDemo_1270892076.zip
Regards,
Deivaselvan
I also ran into this problem with the SfListBox and ended up making my own observable collection/list:
Hi Mike-E,
We are happy to hear that the problem has been resolved by yourself. Please let
us know if you have any other concerns. As always, we will gladly assist you😊.
Regards,
Vijayarasan S