The TreeViewDragDrop expects the ItemsSource of the TreeView and all its items will be an IList. If it is anything else (an IEnumerable or ICollection), inserting an item in the middle of the collection is not supported because these interfaces do not have and Insert() method.
It is quite possible that the data source that the TreeView is bound to is an IEnumerable.
Another possible issue is that the Children collection of the items are not initialized yet. The TreeView will not automatically create Children collections for the ViewModel items it is bound to. This is why the items collections of the items you are binding to need to be initialized at least to an empty collection.
Unfortunately there is no easy way to sort the items of a TreeView. If you use the OrderBy() extension method on a collection the result will be an IEnumerable and drag-drop will not work. You will need to handle the DragDrop events and implement custom logic for inserting an item in an IEnumeravle collection.
Since there is no built-in sorting, custom sorting has to be implemented for the data items.
Could you provide some more information so that we can help you further:
- How do you populate the TreeView?
- How do you implementing sorting of the data?
- Is the result of the sorting an IEnumerable?
We can help you with handling the DragDrop events if the ItemsSource is an IEnumerable, but could you check this first?
the Telerik team