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

Separator during DragAndDrop in RadTreeView

4 Answers 208 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Mingxue
Top achievements
Rank 1
Mingxue asked on 07 Jun 2016, 12:09 AM
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.

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Jun 2016, 01:54 PM
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.
0
Mingxue
Top achievements
Rank 1
answered on 08 Jun 2016, 05:18 PM

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?

0
Accepted
Martin Ivanov
Telerik team
answered on 10 Jun 2016, 02:38 PM
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.
0
Mingxue
Top achievements
Rank 1
answered on 14 Jun 2016, 10:23 PM

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.

Tags
DragAndDrop
Asked by
Mingxue
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Mingxue
Top achievements
Rank 1
Share this question
or