No drag/drop events currently being fired from RadTreeView

4 posts, 1 answers
  1. Praveen
    Praveen avatar
    5 posts
    Member since:
    Apr 2015

    Posted 25 Nov 2015 Link to this post

    Currently, I'm trying to use Drag/Drop in my application however none of the events in relation to this are firing. Is this a known issue? If so, are there workarounds?

    I've also tried to use ItemDoubleClick even which is also not getting fired. 

    Please do let me know. 

    TIA

  2. Ivan
    Admin
    Ivan avatar
    44 posts

    Posted 26 Nov 2015 Link to this post

    Hi Praveen,

    Are you trying to attach to the events described in the Drag and Drop article? If so, keep in mind that before Q2 2014 we used RadDragAndDropManager that uses these events. Since Q2 2014 our TreeView uses new drag/drop implementation through DragDropManager. So far the events cannot be attached from the XAML and this needs to be done in c# code:
    private void SubscribeToDragDropEvents()
    {
       DragDropManager.AddDragInitializeHandler(this.radTreeView, 
    this.HandleDragInitialize, true);
       DragDropManager.AddDragDropCompletedHandler(this.radTreeView, this.HandleDragDropCompleted, true);
    }
     
    private void HandleDragInitialize(object sender, DragInitializeEventArgs e)
    {
       MessageBox.Show("Handle drag initialize");
       e.Handled = true;
    }
     
    private void HandleDragDropCompleted(object sender, DragDropCompletedEventArgs e)
    {
        MessageBox.Show("Handle drag drop completed");
        e.Handled = true;
    }

    You can also read about the DragDropManager here.

    About the double click event, I test it on my side and it is fired as expected.

    Please find a simple demonstration of using these events with the TreeView project attached. 

    If you have further problems with this please let us know and if possible provide us with a sample project demonstrating those issues.

    Regards,
    Ivan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Praveen
    Praveen avatar
    5 posts
    Member since:
    Apr 2015

    Posted 01 Dec 2015 in reply to Ivan Link to this post

    Thanks Ivan. I used OnDropComplete and OnDrop instead. Now the problem I am facing is how to drop the dragged item into the new location. I need to drop an item from one location in RadTreeView to another.
  5. Answer
    Ivan
    Admin
    Ivan avatar
    44 posts

    Posted 01 Dec 2015 Link to this post

    Hello Praveen,

    Normally, RadTreeView supports drag and drop functionality out of the box. You can enable it by setting the IsDragDropEnabled property to true. In the example I gave you the drag/drop doesn't work as expected because of the code in the DragInitialize event handler.
    private void HandleDragInitialize(object sender, DragInitializeEventArgs e)
    {
       MessageBox.Show("Handle drag initialize");
       e.Handled = true;
    }
    The MessageBox in the handler takes the mouse focus. If you comment it you will be able to change the position of the item in the tree.

    If this is not your case please provide us with an example demonstrating the issue, so we can give you more specific ways to resolve it.

    Regards,
    Ivan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top