Drag-drop inconsistency with C1TreeView items

Posted by: jacob.a.buchanan6.ctr on 19 December 2025, 12:05 pm EST

    • Post Options:
    • Link

    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!

  • Posted 22 December 2025, 3:41 pm EST

    Hi Jacob,

    You can refer to the following product sample to learn how drag and drop is implemented in C1TreeView:

    https://github.com/GrapeCity/ComponentOne-WPF-Samples/tree/master/NET_9/TreeView/TreeViewExplorer

    Please review this sample and use it as a reference while implementing the same in your project. If you still face any issues, feel free to share a simplified version of your project along with the problem details.

    Thanks & regards,

    Aastha

  • Posted 15 May 2026, 4:23 pm EST

    Hi Aastha,

    Sorry for the very, very late response.

    When you first made your reply, I looked over the code, and it appeared very similar to our setup. I tried a few things but got nowhere in particular with it. Really the only difference being that you determined whether to insert before or after by doing:

    “bool insertAfter = e.GetPosition(target).Y > 4”

    While in my code we were doing:

    “bool insertAfter = e.GetPosition(target).Y > target.RenderSize.Height”

    So, I tried changing our code to just use " > 4" instead, but it had the same issue, so i benched the problem for now to work on another project.

    Fast forward to today and I finally got time to pull down and try out the sample you linked. I particularly wanted to check if the target insert location in your sample app matched the drag-drop indicator shown in your UI since that is the issue I’m having in my tool. It seems your tool has the same inconsistency as mine.

    Here is my process to repeat the issue:

    1. In your app expand the Sales and Marketing tabs on the Drag & Drop page.
    2. Select and drag “Kevin Brown” over “David Campbell” without releasing the mouse.
    3. Line it up so that the drop indicator in the UI appears just above “David Campbell” to the point where if you move your mouse just a few pixels lower, then the indicator will show below David Campbell.
    4. With the drop indicator above David Campbell release Kevin Brown and note that it will insert Kevin below David, even though the indicator shows that it should have inserted him above David.

    This is more prominent in my app because our Drag-Drop indicators in the UI are much more visible with a thicker black arrow instead of the nearly transparent default arrow. This was done at the user’s request. There is also a lot more moving parts in the background that perform actions whenever an item gets moved around and its specific insert position in the tree has significance. Our users are reporting frustration with the drag-drop capability because it keeps dropping the item in unintended spots.

    This is why I would love it if I could just get the position of the UI component in the tree, so that I don’t need to do any calculations for insert location and instead directly sync my drop location to wherever the UI indicator is at so that there will never be inconsistencies.

    Hopefully this made sense, if not I can try and provide more clarification.

  • Posted 19 May 2026, 4:47 am EST

    Hi Jacob,

    Thank you very much for sharing such a detailed explanation. We were able to observe the exact behavior you described using our product sample. We have shared our findings with the development team to get their insights and will keep you updated.

    [Internal Tracking ID: C1XAML-39715]

    Best Regards,

    Kartik

  • Posted 20 May 2026, 5:18 am EST

    Hi Jacob,

    As per the development team, unfortunately, there is currently no API available to retrieve the exact location of the drop marker during the DragDrop process.

    However, the developer reviewed the internal logic used to determine the marker position and found that the source element moves upward only when the cursor position falls within the upper quarter of the target element’s rendered height.

    Based on this, they suggested a more accurate approach for handling the calculation in the DragDrop handler by computing the upper quarter of the target element as follows:

    double upperQuarter = target.RenderSize.Height / 4;
    bool insertAfter = e.GetPosition(target).Y > upperQuarter;

    We tested this updated code in our product sample, and it appears to resolve the drag-and-drop discrepancy you reported above.

    Best Regards,

    Kartik

  • Posted 20 May 2026, 11:35 am EST

    That worked great! Everything seems to run smoothly now.

    Thanks for your timely help with this issue!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels