RadTreeViewItem.IsDragAllowed

2 posts, 0 answers
  1. Chad
    Chad avatar
    21 posts
    Member since:
    Aug 2013

    Posted 21 Oct 2014 Link to this post

    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,
  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 24 Oct 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top