Posted 19 December 2025, 12:05 pm EST
I have a C1TreeView with numerous nested HierachicalDataTemplates. However, our setup can be simplified to two classes for demo purposes:
public class DataItem
{
public string Name {get;set;}
}
public class GroupDataItem : DataItem
{
public List<DataItem> Children {get; set;}
}
Meaning that you can have groups within groups within groups resulting in multiple levels in our Tree.
During the DragDrop event the DragDropEventArgs.DragSource is the correct dragged item, but our DragDropEventArgs.DropTarget is always just the entire TreeView. We have been using treeView.GetNode(e.GetPosition(null)) to get the C1TreeViewItem at mouse position to act as our DropTarget, this works well but we are having issues with determining where exactly to drop/insert the DragSource. We want our insert to match the indicators from the UI. The DragDrop markers show the DragDropArrowMarker when hovering directly over an item and it shows the DragDropLineMarker when hovering above/below the item.
We essentially want to do like this:
- If the ArrowMarker is shown & if the DropTarget is a GroupDataItem, then insert our DragSource item into the DropTarget(i.e. add to its collection of DataItems).
- If the LineMarker is shown above the DropTarget, then insert the DragSource into the DropTarget’s parent at DropTarget.Index - 1
- If the LineMarker is shown below the DropTarget, then insert the DragSource into the DropTarget’s parent at DropTarget.Index;
We are having issues in determining where the markers are located and which one is showing, so we are having trouble matching our drag-drop logic to what the UI is displaying.
It’s very possible we are just overcomplicating this whole procedure, so any advice would be appreciated!