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

3 posts, 1 answers
  1. Mark
    Mark avatar
    7 posts
    Member since:
    Nov 2010

    Posted 16 Mar 2011 Link to this post

    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. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Mar 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mark
    Mark avatar
    7 posts
    Member since:
    Nov 2010

    Posted 19 Mar 2011 Link to this post

    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
Back to Top