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

RadDragAndDropManager to DragDropManager question

1 Answer 47 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 May 2013, 07:53 PM
I am trying to convert a bit of code from the old RadDragAndDropManager to the new DragDropManager but the documentation is really lacking and I'm having a lot of trouble figuring out what to do.

I just have a simple function that determines whether or not the user can drop a node in a RadTreeView.  I feel like this should be simple to replicate with DragDropManager, but I'm just missing something:

Tree.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(Tree_DragQuery), true);
 
private void Tree_DragQuery(object sender, DragDropQueryEventArgs e)
{
    var targetTvi = e.Options.Destination as RadTreeViewItem;
    var sourceTvi = e.Options.Source as RadTreeViewItem;
 
    if (targetTvi == null || sourceTvi == null)
    {
        return;
    }
 
    if (sourceTvi.DataContext is LayerTviVM && targetTvi.DataContext is LayerTviVM)
    {
        e.QueryResult = true;
    }
    else if (sourceTvi.DataContext is ImageTviVM && targetTvi.DataContext is ImageTviVM)
    {
        // We only support drag & drop of images within the same layer
        e.QueryResult = (sourceTvi.ParentItem == targetTvi.ParentItem);
    }
    else
    {
        e.QueryResult = false;
    }
}

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 May 2013, 01:23 PM
Hi Chris,

Generally, this can be achieved by modifying the DragDropEffects of the current drag operation by using the DragOver event. 

You can achieve the functionality in your question by setting the effects of the current drag operation to None.

The usage of the drag effects can be seen here

Regards,
Yoan
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DragAndDrop
Asked by
Chris
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or