DragAndDropTarget with TreeViewItem


Hi folks, I’m looking to simply rearrange the TreeViewItems in my TreeView by dragging and dropping. So I’ve got my TreeView inside a DragAndDropContainer component, and I’ve made my TreeViewItem subclass inherit from DragAndDropTarget. However, this doesn’t seem to work. None of the DragAndDropTarget callbacks get called when I drag one TreeViewItem onto another. Am I not able to have TreeViewItems as DragAndDropTargets?


There’s not much point in making a TreeViewItem a drag-listener, because it’s not actually a component on screen, so the UI will never find it as a drag target. Only components can be used to respond to drag events. You can do it by creating a custom tree with your own components for the items, then making those components drag listeners.

There’s probably a good case for me adding some more built-in drag+drop functionality to the treeview…