2
Vote

Insert/Drop events not bound at root of tree.

description

If I take the drag-and-drop sample and try to turn on the insert functionality at the root node, it fails because the root node isn't bound to a TreeViewExItem; it's bound to the TreeViewEx. TreeViewExItem.ParentTreeViewItem is null for nodes immediately below the root, so DragNDropController.CanInsert and OnDrop do nothing.

I "resolved" this issue in my copy by having TreeViewExItem and TreeViewEx implement the attached interface, and then replacing references in CanInsert and OnDrop to ParentTreeViewItem with this new TreeViewExItem property:

internal IDragNDrop ParentDragNDrop { get { return ItemsControl.ItemsControlFromItemContainer(this) as IDragNDrop; } }

This way I can bind drag/drop properties on the root node at the TreeViewEx element. It works, but it's kinda ugly.

file attachments

comments

onelogintoomany wrote Jul 14, 2014 at 4:49 PM

Modifications to TreeViewEx also attached.

slompf wrote Aug 3, 2014 at 3:02 PM

You are right, thats an principal problem. The only solution I see, is to rebuild the dragNdrop. That wouldnt bother me to much, because Im not that happy with it anyway.

The idea is to add functions to the treeviewex itself, which are called if something needs to be dragged, dropped or inserted. That could be done over Events (which are hard to bind to view models) or some ICommand-like interfaces (what I would prefer).

wrote Aug 3, 2014 at 3:02 PM

wrote Aug 5, 2014 at 9:14 AM

nkast wrote Oct 23, 2014 at 3:31 PM

Hi slompf,

What is the status of moving DragNDrop events to TreeViewEx?
The changes by onelogintoomany seems like a good refactoring starting point.

nkast wrote Nov 27, 2014 at 3:31 PM

@onelogintoomany ,@slompf
I forked the project to gitHub and rewrote the Drag&Drop events as Commands.
https://github.com/tainicom/TreeViewEx/tree/DragAndDropCommands

Still, Drop to the root don't work yet. I am working on it.

nkast wrote Nov 27, 2014 at 4:27 PM

ok, just fixed insert/drop to root as well.