RadTreeview dropping on itself

3 posts, 0 answers
  1. paul orsillo
    paul orsillo avatar
    31 posts
    Member since:
    Jan 2010

    Posted 01 Sep 2010 Link to this post

    I have a radtreeview that is a drag source only. It should never accept a drop.

    My properties on the RadTreeView are:
    IsDragDropEnabled="True"  (I need drag)
    AllowDrop="False"
    dragDrop:RadDragAndDropManager.AllowDrop="False"
    AddHandlers for RadDragAndDropManager.DropQueryEvent and RadDragAndDropManager.DropInfoEvent (I added these in a final attempt to consume the event and disallow the drop)

    Despite this, if a node is sourced from the tree view and released onto a sibling node in the same treeview the drop is accepted as a drop/copy and the node is added as a child.

    To be a little more clear: The tree has a single level (i.e. all nodes are siblings).

    If I move a selected node around in the tree NOT over another node and release, the drop is rejected and nothing happens. So far so good. But if I drop over a sibling node, the sibling node highlights. If I release at that moment the drop is accepted and the payload node is copied as a child of the highlighted node.

    As you can see I have taken the programming equivalent of a hammer to try to get the desired behavior and so far have failed.  Is there a correct way to achieve this?

    Thank you,
    Paul
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 06 Sep 2010 Link to this post

    Hi paul orsillo,

    In order to disable dropping onto the same RadTreeView, you need to handle the PreviewDragEnded() event:
    private void treeView1_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
    {
        e.Handled = true;
    }

    If you choose to use this approach you won't need to set dragDrop:RadDragAndDropManager.AllowDrop property or handle the OnDropQuery() and OnDropInfo() events. Also, the AllowDrop property controls whether the RadTreeView can be a drop target for purposes of Silverlight native drag-and-drop operations (like dropping files on the plugin), which are different from the TreeView DragAndDrop operations.

    Therefore the definition of your RadTreeView can be:
    <telerik:RadTreeView x:Name="treeView1"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ItemTemplate="{StaticResource ItemTemplate}"
                         IsDragDropEnabled="True"
                         PreviewDragEnded="treeView1_PreviewDragEnded"/>

    You can also take a look at this forum thread, where similar scenario is discussed.

    I hope this information helps.

    Best wishes,
    Tina Stancheva
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. paul orsillo
    paul orsillo avatar
    31 posts
    Member since:
    Jan 2010

    Posted 07 Sep 2010 Link to this post

    Well gee, it works exactly as you say.
    That was simple enough.
    Thank you. 
    Paul
Back to Top