Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Drag node from XamDataTree onto XamDiagram

In my application, I have a XamDataTree, and I want to be able to drag a node from the tree and drop it onto a XamDiagram and have a node created for it there.

However, I am having trouble setting the XamDiagram as a drop target. When I do drop the node onto the XamDiagram and the XamDataTree_NodeDragDrop event handler is called, the DragDropEventArgs.DropTarget is not of type XamDiagram, but instead of type Border, where for some reason, the Border looks to be the container border for the XamDiagram's options pane.

My xaml looks like this:

<ig:XamDataTree x:Name="MyDataTree"
                        ItemsSource="{Binding Source={StaticResource DataUtil}, Path=CategoriesAndProducts}"
<ig:XamDiagram x:Name="MyDiagram">
        <ig:DropTarget IsDropTarget="True"
                    DropTargetMarkerBrush="Azure" />

And my XamDataTree_NodeDragDrop looks like this:

private void MyDataTree_NodeDragDrop(object sender, TreeDropEventArgs e)
            XamDataTreeNodeControl draggedNode = e.DragDropEventArgs.DragSource as XamDataTreeNodeControl;
            object data = (draggedNode?.DataContext as XamDataTreeNodeDataContext)?.Data;
            UIElement dropTarget = e.DragDropEventArgs.DropTarget;

            if (dropTarget is XamDiagram) // This evaluates to false
                // Add new node to diagram
            else if (dropTarget is Border) // This evaluates to true
                // Why is the drop target not the XamDiagram??

It almost seems as is the XamDiagram's options pane is also set as a drop target by default and is somehow catching the drop events before they can bubble up to the XamDiagram itself.

Why might this behavior be occurring? Am I defining the drop target on the XamDiagram incorrectly?

  • 28185
    Offline posted

    Hello Andrew, 

    Thank you for contacting Infragistics. Your code appears to be fine, and the reasoning might be because the XamDiagram has it's own drag functionality that might be interfering. At this time I don't have any workarounds or suggestions to provide. I will need to spend some time building an isolated sample to investigate this in depth. I'll follow up next week regarding my progress. If you have something you wish to share to help me reproduce this quickly I'd greatly appreciate it. Let me know if you have any questions.

  • 130
    Offline posted in reply to Michael DiFilippo

    Hello Michael,

    Thanks for the quick response!  I was able to isolate and reproduce this issue on a test project, which I have linked below:

    For a bit of additional information, I also attempted to wrap the XamDiagram in a parent UserControl and set that UserControl as a drop target instead, with no luck. So whatever drag/drop functionality that the XamDiagram is using internally seems to be preventing any other controls further up in the tree from receiving drop events.

    I assumed that if I were able to separate this out into channels, I'd be able to prevent the XamDiagram drag/drop from interfering with my custom drag/drop, but I cannot seem to figure out any way to set channels on drag/drop events for XamDataTree nodes, so that might not be an option.

    Essentially, I need to be able to perform drag/drop within the XamDataTree (as per its default drag/drop functionality), and I also need to be able to drag/drop tree nodes to other controls outside of the XamDataTree. I have been able to to that with other controls, but not with the XamDiagram.

Reply Children
No Data