Using the ShowBetweenItemsDragCue method on RadTreeView

3 posts, 1 answers
  1. Simon Stahl
    Simon Stahl avatar
    10 posts
    Member since:
    Apr 2009

    Posted 21 Nov 2009 Link to this post

    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. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Nov 2009 Link to this post

    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.
  3. DevCraft banner
  4. Simon Stahl
    Simon Stahl avatar
    10 posts
    Member since:
    Apr 2009

    Posted 26 Nov 2009 Link to this post

    Hi Miroslav

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

    greez simon
Back to Top