I'm populating a TreeView through a XmlDataProvider, and have already implemented Drag-and-drop functionality, so I can move nodes around, and drop nodes from other locations.
But I have only implemented the simplest form; when you drop, it's inserted as a child to the node which on which it is dropped. This functionality works as intended. But I also want the ability to drop an item between two nodes, so that it becomes a sibling instead.
How should I proceed to solve this?
Currently I'm using a HierarchicalDataTemplate, with a StackPanel:
<HierarchicalDataTemplate x:Key="XmlTreeTemplate">
<HierarchicalDataTemplate.ItemsSource>
<Binding XPath="child::node()" />
</HierarchicalDataTemplate.ItemsSource>
<StackPanel
AllowDrop="True"
DragEnter="StackPanelDragEnter"
DragLeave="StackPanelDragLeave"
DragOver="StackPanelDragOver"
...
The Drop event is on the TreeView.