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

RadTreeViewItem Events

4 Answers 71 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ziad
Top achievements
Rank 1
Ziad asked on 06 Nov 2009, 09:14 AM
Hello, from what I understood based on the previous threads here, the DragEnter, DragOver, Drop... events from

4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 10 Nov 2009, 08:26 AM
Hi Ziad,

Yes, we expose  different DragDrop events than the one on UIElement.

Please note that the RadDragAndDropManager does not work across different windows or different applications in WPF. If you need this functionality, you will still need to handle the built-in DragDrop events.

Otherwise you can find an example of drag-drop implementation between different controls in the online examples:

http://demos.telerik.com/wpf/

Go to DragDrop -> Tree to Grid

There you can see how some of the DragDrop events are handled to implement dragging products across different controls.

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
Ziad
Top achievements
Rank 1
answered on 12 Nov 2009, 10:02 AM
Hello Miroslav and thank you for your reply.

In my specific case, I have a three-level tree view hierarchy. The treeview has to abide by certain restrictions when it comes to drag/drop behavior. For example, you can only drag/drop items in the same 'level'. In addition, there is a default tree item which you cannot add items to. In order to accomplish this behavior, I need to capture events such as 'PreviewDrop' and 'PreviewDragEnter'. I tried attaching event handlers to 'DragDrop.PreviewDrop' and 'UIElement.PreviewDrop'. However, neither of these events were being fired when I was dropping items.

How can I capture these (or at least similar) events in order to control which items are allowed to be dragged and dropped?


Thank you.
0
Accepted
Kiril Stanoev
Telerik team
answered on 18 Nov 2009, 12:11 PM
Hi Ziad,

In your case you have to add a handler to RadDragAndDropManager.DropQueryEvent and handle even the handled events.

this.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(RadTreeView_DropQuery), true);

In the event handler you can place your logic for determining whether a drop is possible or not.

private void RadTreeView_DropQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e)
{
    bool dropPossible = this.DetermineWhetherDropIsPossible();
 
    if(dropPossible)
    {
        e.QueryResult = true;
    }
    else
    {
        e.QueryResult = false;
    }
}

I have attached a sample project that demonstrates the above functionality with 3 level hierarchy. Have a look at it and let me know if it is of any help.

Sincerely yours,
Kiril Stanoev
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
Ziad
Top achievements
Rank 1
answered on 29 Dec 2009, 08:47 AM
Thank you Kiril, this is exactly what I was looking for.
Tags
TreeView
Asked by
Ziad
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Ziad
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or