I'm using XamDataTree to show a hierarchical data structure that has the following structure:
Group -> Product -> License
Where each Group contains an ObservableCollection of Products, and each Product contains an ObservableCollection of Licenses.
I'm using the standard Infragistics WPF Drag & Drog framework to allow drag and drop operations for the nodes in the tree. For the basic functionality of moving nodes around or dropping them on their parent category, it works great just by adding IsDraggable="true" and IsDropTarget="true" to the XamDataTree. However, I want to allow a user to drop a License node directly onto a Group node and allow my code-behind logic to create the appropriate Product node in the tree (well...the model behind the tree).
I believe that I can achieve this by overriding the default DragOver & Drop events, but my main question is this: Is there a way to override these events, add my business logic, and then call the base events? Basically I would have a special case for when the drag drop operation was for a License node being dropped onto a Group, otherwise I want the default functionality. I hope this makes sense, and maybe someone can lead me in the right direction.
Hi Daniel,
I believe I've come up with a usuable solution that will allow you to keep the default behavior but also let you drag License nodes onto Group nodes so you can perform the desired logic. I've attached my sample below.
The basic idea was that even though the data tree doesn't allow License nodes to be dropped onto Group nodes, the Drop event still fires if you try to drop the License node onto a Group node. And fortunately it tells you exactly which node you dropped on to. This means it's possible to do the drag and drop if you handle the drop code yourself. The bad news is that the icon still shows the user that they can't drop onto the Group node. To get around this, I handled the DragEnter event and if the user is dragging a License node over the Group node I change the "NotAllowed" template to one that looks like it is allowed. This way the user has feedback that they can make a valid drop.
Take a look at the sample and let me know if you have any questions on it.
Rob,
Thank you for looking into my issue. Since the XamDataTree cannot allow the DD manager to drop a License node into a Group node, what I would like to do is override the default DragOver & Drop events to give the user a visual cue that they can still perform that drag drop operation. Then, upon a drop of a License onto a Group node, add a Product node to the Group, then add the License node to the Product. This way, the logical model is kept intact. I'm just not sure how to do this without rewriting the entire drag drop framework. I would certainly appreciate any further ideas or help.
-Daniel
I'm still looking into this for you. Currently I haven't been able to get this working when the default drag and drop behavior is enabled. The XamDataTree is internally keeping the drag drop manager from allowing the user to drag a node from the License area to the Group area. It does this because it can't actually add the License node to the Group's Product collection since the object types don't match. I'm looking for a way around this and I will let you know once I find it.