Enable Only Drop Inside
This tutorial demonstrates how to enable dropping inside the RadTreeViewItems, but not around them.
For the purpose of this tutorial will be used the following treeview declaration:
The RadTreeView is data bound to a collection of business objects. For more information, read the Binding to Object topic.
In order to implement only drop inside you need to perform the following steps:
-
Attach to the DragDropManager DragOver event:
RadTreeView handles internally the DragDropManager events and in order to invoke a custom handler, you need to explicitly specify that you're adding a handler that should be invoked even for already handled events. This is done through the last - bool argument of the DragDropManager.AddDragOverHandler extension method.
-
In the event handler you should use the following code:
Please note that if you want the changes applied on the TreeViewDragDropOptions object to affect the DragVisual element, you have to invoke the UpdateDragVisual() method.
Find a runnable project of the previous example in the WPF Samples GitHub repository.