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

RadTreeViewItem.IsDragAllowed

1 Answer 66 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 22 Oct 2014, 02:33 AM
There is an IsDropAllowed property but no IsDragAllowed, have I missed it or an equivalent property or will I have to revert to a coding solution?

Thank you,

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 24 Oct 2014, 09:14 AM
Hi Tjaart,

The default drag and drop behavior of RadTreeView uses our DragDropManager to implement its logic. The manager have AllowDrag (and AllowCaptureDrag) attached properties which are set on the RadTreeViewItems and determines if the item can be dragged.  However, if a child property have this property set to false, the drag events will bubble to its parent. 

In order to forbid the drag of an item you can subscribe for the DragInitialize event of DragDropmanager and inside its handler set the Data and the DragVisual to null. Here is an example in code:

DragDropManager.AddDragInitializeHandler(this.tree, OnDragInit, true);
...................
private void OnDragInit(object sender, DragInitializeEventArgs e)
{
    var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as  TreeViewDragDropOptions;
    if (options != null)
    {
        if (the currently prepared item should not be dragged)
        {
            e.Data = null;
            e.DragVisual = null;
        }
    }
}

Regards,
Martin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Chad
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or