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
95
Drag-Drop between 2 XamDataTrees
posted

I have a situation where I have 2 XamDataTrees that I need to be able to drag and drop items from one to the other.

  • Tree 2 needs to drag items into Tree 1.
  • Tree 1 needs to drag items around within itself.
  • Tree 2 is not a drop target for either tree.

Data structure consists of Schemas, Groups, Nodes, Leaves:

  • Schemas and groups exist in Tree 1
  • Nodes and leaves exist in Tree 2
  • Schemas can only contain groups (consider a schema a "root")
  • Groups can contain other groups, nodes, and leaves
  • Nodes contain other nodes and leaves
  • Leaves contain nothing (dead end)

What we want to achieve with dragging:

  • dragging groups into schemas or other groups (within Tree 1)
  • dragging groups, nodes or leaves into groups (within Tree 1)
  • dragging nodes or leaves into groups (from Tree 2 into Tree 1)
  • disable dragging nodes or leaves into schemas (from Tree 2 into Tree 1)
  • disable dragging schemas into other schemas (within Tree 1)

Since the tree is particular about the type when dragging and dropping, this is proving to be a challenging problem. Deriving from a base type gets things working, but I can't disallow things like dragging a node from Tree 2 into a schema in Tree 1. This seems to be a problem of the IsDropTarget being conditional on what the drag source type is and I can't figure out how to make that happen with this control. Any help would be appreciated.

Parents
No Data
Reply
  • 34690
    Offline posted

    Hello Tracie,

    I have been investigating into your requirement, and at the moment, none of the drag-drop related events that the XamDataTree exposes will really let you restrict drag and drop from one node to another, especially if they are all derived from a base type and the collections that make up your layout are child collections of that base type as you have mentioned.

    With that said, some time ago I did derive a solution for another forum thread discussion using the IsEnabledMemberPath of the NodeLayout and the NodeDraggingStart and NodeDragEnd events so that you can disable certain underlying data items from being dragged to depending on the type that you are currently dragging. That forum thread, along with a sample project I wrote for it is located here: https://es.infragistics.com/community/forums/f/retired-products-and-controls/105253/xamdatatree-drag-drop-within-the-parent-node. Please disregard the mentioning of the “Silverlight” XamDataTree, as the XamDataTree was a shared control between Silverlight and WPF, back when we still supported Silverlight.

    By setting the underlying property that the IsEnabledMemberPath is pointed at such that some nodes will be disabled, your end user will not be able to drag to the nodes that are disabled. The same can be said from Tree 1 to Tree 2 in this case if you mark the IsEnabledMemberPath for all of the items in Tree 2 to be disabled when a node begins dragging in Tree 1. Then, you can reset the underlying IsEnabledMemberPath property in the NodeDragEnd event.

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

Children