I've got a XamDataTree that we allow drag/drop within, both copying and moving. If I copy an item into a certain node, the tree will allow me to continue adding that same item within that same node. So I can end up with many of the same items within that node, where I'd like to constrain it to not allow duplicates. Is there a way to do this? A wrinkle to this is that my tree is fairly complex and some of the types derive from a common base which forces me to work around some of the default behavior of the tree.
I have been investigating into your requirement in this case, and at the moment, there is nothing built-in to the XamDataTree that will prevent users from dragging and dropping a duplicate data item into a level of the tree by default. This will need to be achieved in application code, either before the drop operation happens, or after the drop is attempted.
My recommendation for before the drop operation happens essentially exists in another forum thread that we had together, which I am linking here. Specifically, the part about using the IsEnabledMemberPath on your underlying data item. You would need to check child collections for the dragged item when the drag starts and disable all nodes on that level if you are trying to prevent the drag to them.
My recommendation for after the drag would involve handling the NodeDragDrop event of the XamDataTree, and querying the nodes of the level that you are trying to drag and drop to in that event, as that event fires when the drop happens. I am attaching a sample project that demonstrates the querying of these nodes, as this should help you to prevent dragging any duplicates to a level of the tree.
Please let me know if you have any other questions or concerns on this matter.
Thanks so much for the reply. I think (hope) this gets me headed in the right direction. I am opting for your second solution (after the drag) since the complexity of our data model is such that I need to know more about the droptarget than the duplicate children. But this appears to help.