This is a migrated thread and some comments may be shown as answers.

Drag and Drop multiple items between each other causes them to disappear in TreeView

2 Answers 168 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Mar 2011, 03:54 PM
Hello,

I am using version 2010.3.1314.35.  I have a TreeView that binds to an ObservableCollection<>, and I am allowing dragging and dropping to move items around.  Everything works great and gets updated nicely (I am implementing INotifyPropertyChanged on my objects), except for the following:

When a user selects multiple items in the TreeView and attempts to drop them in between the same selected items.  The result is that the items completely disappear from view.  I have attached a screen capture to show what I am referring to.

I was hoping that there is an easy way to handle this, but maybe I have to add some custom logic to my RadDragAndDropManager.DropQueryEvent (or perhaps my PreviewDragEnded event) to prevent such an occurrence?  I'm trying to avoid having to check if the selected items are surrounding the target destination (which I assume is what is causing the disappearance).

Any help or direction on this would be greatly appreciated!

Cheers,
Mark

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 19 Mar 2011, 01:45 PM
Hi Mark,

I prepared a sample for you just for showing that dragging MultipleItems without copy works "out of the box" with Q3 2010 SP1 `s RadTreeView for WPF 3.5. The block of items you have selected cannot be moved into one of the SelectedItems or between them which is expected.
However, your scenario has different custom application logic. You will have to copy the Items you are dragging in order to drop them inside one of them or between them.The copy function is essential since the RadTreeView won't let a user to drag a parent item into one of its children or itself.
You will definitely need some checks related to the DropTarget ( RadTreeViewItem or RadTreeView) and DropPosition(Before, After, Inside). Additionally, the DragCue may need correction(in order to show that a D'N'D operation is possible). Feel free to ask if you need further assistance on this.

All the best,
Petar Mladenov
the Telerik team
0
Mark
Top achievements
Rank 1
answered on 19 Mar 2011, 04:25 PM
Once you mentioned that "out of the box" it works, it got me thinking about my existing application logic in my OnDropQuery event.  Alas, I had the following logic at the end:
else
{
   e.QueryResult = true;
}

Thanks for pointing me in the right direction!  I didn't realize that by not setting the QueryResult after implementing OnDropQuery will still let the "out of box" logic execute.

Cheers,
Mark
Tags
DragAndDrop
Asked by
Mark
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or