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

RadTreeview dropping on itself

2 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
paul orsillo
Top achievements
Rank 1
paul orsillo asked on 01 Sep 2010, 02:28 PM
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 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 06 Sep 2010, 02:10 PM
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
0
paul orsillo
Top achievements
Rank 1
answered on 07 Sep 2010, 01:52 PM
Well gee, it works exactly as you say.
That was simple enough.
Thank you. 
Paul
Tags
General Discussions
Asked by
paul orsillo
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
paul orsillo
Top achievements
Rank 1
Share this question
or