Separator during DragAndDrop in RadTreeView

5 posts, 1 answers
  1. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 06 Jun Link to this post

    Hi,
    I have learned about DragAndDrop from some samples and throughout the forum. But I am having issue for the issue below.

    Basically, I am trying to create my own DragAndDropProvider, and tried to created my own DragVisual during DragAndDrop events. And I find the best visual for DragAndDrop is the Separator visual effect from built-in support. So I set the default property "IsDragDropEnabled = True" in my RadTreeView, but it seems if I do so, my DragAndDropProvider won't trigger anymore.

      

    The XAML code looks like this:

            <telerik:RadTreeView x:Name="ReportTreeView"
                                 Grid.Row="1"
                                 IsEditable="True"
                                 ItemsSource="{Binding Pages}"
                                 ItemDoubleClick="ReportTreeView_OnItemDoubleClick"
                                 Selected="ReportTreeView_OnSelected"
                                 ItemContainerStyle="{StaticResource PageStyle}"
                                 IsDragDropEnabled="True"
                                 uxHelpers:PageDragAndDropProvider.IsEnabled ="True">

     

    What should I do to benefit from both the customized DragAndDropProvider and built-in DragDrop Separator?

     

    Thanks,

    Mingxue.

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 08 Jun Link to this post

    Hello Mingxue,

    Without  your implementation I cannot be sure why the events do not fire. But I am going to guess this is caused by the fact that the subscriptions to the DragDropManager events in your DragAndDropProvider doesn't take the handled events into account. 

    RadTreeView is using DragDropManager to implement its drag feature. The internal implementation handles the manager's events and this is why if you enable the drag/drop feature and then try to subscribe to the events they won't be fired. In order to work this around you can set the last parameter of the Add[eventname]Handler() methods to true. For example:
    DragDropManager.AddDragOverHandler(this.treeview, OnDragOver,true);
    You can read the Drag and Drop help article to see how to customize the treeview's default drag/drop behavior.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 08 Jun in reply to Martin Link to this post

    Thanks for your help. With the new eventHandler subscription API, the event fires. However, the real problem still exists.

    What I wanted is the Drop Preview Line visible during my drag and drop. It seems this Drop preview line is only visible if I rely on the internal RadTreeView drag and drop manager to handle it. Whenever I try to customize my own handler, this Drop Preview Line disappears.

    What can I do to customize the Drag and drop handler, while being able to see Drop Preview Line?

  5. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 10 Jun Link to this post

    Hi Mingxue,

    The drop preview line is designed to work automatically only with default drag/drop functionality of RadTreeView. If you want to display it with custom implementation that doesn't uses the default drag/drop you will need to handle the preview line manually. Luckily, RadTreeView provides an API that allows you to position the line with less effort. You can use the UpdateDropPreviewLine() method of the treeview.
    treeView.UpdateDropPreviewLine(dropTargetTreeViewItem, dropPosition);

    I hope this helps.

    Regards,
    Martin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  6. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 14 Jun in reply to Martin Link to this post

    Thanks for your reply.

    I did some research on the forum based on this new API you provided, it did help me a lot.

    My final solution is to use the build-in behavior of RadTreeView, and only subscribe to OnDragOver and OnDropPreview evnets.

    This way, I can get the built-in object from OnDragInitialize, note that I don't subscribe to it, so I can get this:

    DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;

    This built-in object has everything I needed to handle my own TreeView Drag and Drop behaviors, and I would recommend whoever is in the same situation as me do the same. Save much effort in UI work, and can help focus on the logic behind.

Back to Top
UI for WPF is Visual Studio 2017 Ready