I have several treeviews generated by a ItemsControl, and I'd like to disable the ability to drop an element on the root level. (Basically, you can reorder subtrees, but you can't create a new root).
I tried attaching an event to drag and drop of the tree view like that
for (int i = 0; i < Trees.Items.Count; i++)
{
var uiElement =
(ContentPresenter)Trees.ItemContainerGenerator.ContainerFromIndex(i);
if (uiElement == null)
continue;
RadTreeView dependencyObject = VisualTreeHelper.GetChild(uiElement,0) as RadTreeView;
DragDropManager.AddDragOverHandler(dependencyObject,OnDragOver,true);
DragDropManager.AddDragInitializeHandler(dependencyObject,OnDragInit,true);
}
But the event does not seem to fire.
Any hint on how to achieve what I want ?
I tried attaching an event to drag and drop of the tree view like that
for (int i = 0; i < Trees.Items.Count; i++)
{
var uiElement =
(ContentPresenter)Trees.ItemContainerGenerator.ContainerFromIndex(i);
if (uiElement == null)
continue;
RadTreeView dependencyObject = VisualTreeHelper.GetChild(uiElement,0) as RadTreeView;
DragDropManager.AddDragOverHandler(dependencyObject,OnDragOver,true);
DragDropManager.AddDragInitializeHandler(dependencyObject,OnDragInit,true);
}
But the event does not seem to fire.
Any hint on how to achieve what I want ?