Drag-Drop in treeview, insert between nodes Drag-Drop in treeview, insert between nodes wpf wpf

Drag-Drop in treeview, insert between nodes


During DragOver you can determine if your mouse position is above or below your TreeView Node with this method:

    public static bool IsInFirstHalf(FrameworkElement container, Point mousePosition, Orientation orientation)    {        if (orientation == Orientation.Vertical)        {            return mousePosition.Y < container.ActualHeight / 2;        }        return mousePosition.X < container.ActualWidth / 2;    }

Then display an insertion adorner before/after your node.On Drop create a new node either before ( child of the parent node) or after ( sibling) the dropped on node.