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

Using the ShowBetweenItemsDragCue method on RadTreeView

2 Answers 44 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Simon Stahl
Top achievements
Rank 1
Simon Stahl asked on 21 Nov 2009, 01:45 PM
Hi there

I'm currently playing around with the RadTreeView Drag and Drop. I Really like the built in version of it, but could not find a way to get more control over it. I would like every node in the tree to be draggable, but define some dynamic custom rules where it can be dropped. As I could't figure out a way to do this, I started experimenting with the extended Drag and Drop functionality using the RadDragAndDropManager. This is a really nice feature as well, but i ran into another problem with it; how can I figure out the dragging position for using the ShowBetweenItemsDragCue method?
Or, my real question would be: are there any extended Drag and Drop examples available that also shows the use of the ShowBetweenItemsDragCue method?

Thanks in advance
Simon

2 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav
Telerik team
answered on 23 Nov 2009, 05:47 PM
Hello Simon Stahl,

The TreeView uses the DragDrop manager internally, so that anything that you have come across for it will be helpful when you want to customize the drag-drop.

I believe that almost any business rule can be implemented just by handling the DropQuery event for TreeView, there should no need to get into the "internals" like the ShowBetweenItemsDragCue method.

This online example shows what handling of the DragDrop events can achieve:

http://demos.telerik.com/silverlight/#DragAndDrop/TreeToGrid

Also I have attached to this reply a more specific example that shows how the  TreeView's behavior can be modified by handling the DragDrop events.

As for your specific questions, we can look at it this from two angles:

1. How do you know if the mouse is above / below an item?
 - You can use the item.TransformToVisual(null).Transform(new Point()) to get the absolute position of the top left point for the TreeViewItem. Then you need to know the header height of the item, you may go into calculating this as well, but for most purposes you can assume that it is 24 (the default MinHeight).  Then you can use the e.Options.CurrentDragPoint to calculate whether the mouse is below, over or after an item.

2. How do you tell the DragCue where to appear?
The item that is passed as a parameter to the ShowBetweenItemsDragCue method will serve as a guiding point. Then depending on its DropPosition property, the cue will appear bellow or above it.

Hopefully this will help you implement what you need. If you have questions, do come back to us.

All the best,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Simon Stahl
Top achievements
Rank 1
answered on 26 Nov 2009, 08:13 PM
Hi Miroslav

thank you very much for this example, it was really helpful!

greez simon
Tags
DragAndDrop
Asked by
Simon Stahl
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Simon Stahl
Top achievements
Rank 1
Share this question
or