Hi,
I was not able to find this answer on the forum. It looks like a simple thing to do but I was not able to understand it.
I have three RadTreeView with the following xaml options: (IsDragDropEnabled="True" AllowDrop="True" telerik:ScrollingSettingsBehavior.IsEnabled="False" IsDragTooltipEnabled="False") . All three Trees have 2 level of data of 2 different type of objects.
The drop of an item might be allowed or not, depending on a combination on:
- the origin tree of the Drag (tree 1, 2 or 3)
- the type of object selected (level 1 or level 2)
- the target tree (tree 1,2 or 3)
- the drop position (inside, after, before)
As an example, the level 2 objects of tree 1 cannot be dropped on tree 3, while on tree 2 the can only be dropped inside the level 1, or before/after the level 2 (not inside level 2).
I implemented all the controls to allow this behaviour in the handler of "DragDropManager.AddDropHandler", in which when the drop is not allowed I simply have that the DropAction = DropAction.None and everything is working fine.
However what I would like to have is that when the drop is not supposed to be allowed, the drop preview should not be visible. by drop preview I mean the line in between items when the drop position is after/before or the highlight of the target item when the drop position is inside. Note that I still would like to keep the drag preview of the source item, and that I disabled the dragtooltip as not of interest.
I considered using the handler "DragDropManager.AddDragInitializeHandler" to set the AllowDrop to false for all the correct items, however sometimes (like in the example above) I want to disable the drop only for certain drop positions, thus the item AllowDrop property cannot be set to false at the beginning of the drag.
What I think I should do is to use the handler "DragDropManager.AddDragOverHandler", in which I check if the drop is feasible. If it is not, I somehow disable the drop preview, if it is allowed, i enable it once again. This is where I'm stuck.
Considering the variable var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
If after checking that the drop is not allowed I set options.DropTargetItem.AllowDrop = false, the visual result is exactly what I need. However, from that moment on the handler "DragDropManager.AddDragOverHandler" does not fire anymore on that Item, so I cannot set it again to true.
If instead I set options.DropTargetItem.IsDropAllowed = false; nothing happens.
I tried to play with the dragvisual property, setting as an example the dragVisual.IsDropPossible = false, but it doesn't change the result (I guess that this property is only for the dragtooltip that I disabled)
Note that, if possible, I also do not want to override the drop position from the not allowed to the allowed one, like suggested in the documentation (https://docs.telerik.com/devtools/wpf/controls/radtreeview/how-to/drag-and-drop/enabled-drop-inside-only).
Could you please suggest me how to proceed? Please let me know if you need more information.
Thanks in advance for your help.