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
3806
xamdatatree drag drop within the parent node
posted

I looked into the implement Drag Drop for my XamDataTree control.http://help.infragistics.com/Help/Doc/WPF/2011.2/CLR4.0/html/xamDataTree_Drag_and_Drop.html

But I want to limit the drag drop within the parent node and not allow to move the child node to any other parent. How can I achieve this?

  • 34810
    Offline posted

    Hello Gajender,

    Thank you for your post.

    In the Silverlight version of the XamDataTree, the tree has multiple drag-related events that can be handled such as NodeDraggingStart, NodeDragEnd, etc, but none of these can really prevent the tree from being able to drop a child into another child's section of the tree, as the only cancellable event here is the NodeDraggingStart event, and I can't imagine you wish to prevent dragging of your XamDataTree nodes outright.

    Instead, I would recommend that you place a bool property on your data items that you are displaying in your tree that is initially true for all data items. When you define the NodeLayouts for your tree, you can point the NodeLayout.IsEnabledMemberPath to this property name and handle the XamDataTree's NodeDraggingStart event and the NodeDragEnd event. In the NodeDraggingStart event, I would recommend that you check e.Data (where e is the event arguments of the event handler) for a XamDataTreeNode object, and get the Data property from that node. If it is of the type of one of your child objects, then I would recommend that you find all of the other child objects that belong to that particular node layout by looping through your data source. You can then set the IsEnabledMemberPath property on these objects to false to disable dropping the node onto them. In the NodeDragEnd event, you can set all of the IsEnabledMemberPath properties back to true. This will essentially disable all of the nodes in other child bands while you are dragging, and re-enable them when you drop the node.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    There is another option here, as well, and that would be to implement your own custom drag-drop functionality in the XamDataTree by modifying the template of the XamDataTreeNodeControl and using the Infragistics Drag-Drop Framework. Here is a link to a separate forum thread about how this can be achieved: https://es.infragistics.com/community/forums/f/ultimate-ui-for-wpf/57497/xamdatatree---drag-drop-events.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    https://es.infragistics.com/support

    XamDataTreeDragDropCase.zip