How to implement something like "IsDroppingAllowed " with RadTreeView

2 posts, 0 answers
  1. koala
    koala avatar
    7 posts
    Member since:
    Apr 2015

    Posted 21 Apr 2015 Link to this post

    I have a RadTreeView with some Containers and some Items (the items do not contain other items). When I activate Drag and Drop everything works fine. My problem is that I have some Containers that should not work as drop target. Unfortunatly I could not find an example.

    First I tried the property IsDroppingAllowed (I used it like IsExpanded and IsSelected). Unfortunatly the getter is never called.

    Than I tried "OnDragOver"

    DragDropManager.AddDragOverHandler(this.FolderRadTreeView, new Telerik.Windows.DragDrop.DragEventHandler(OnDragOver), true);

    It seems that I have to set 
    options.DropAction = DropAction.Move;


    options.DropAction = DropAction.None;

    and everything works fine. But after a while it drives me crazy. Is there anywhere a good example? Is there anywhere a checklist what I have to reimplement? 

    I tried to use the DropTargetItem to check if the dropping is allowed.

    var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
    var dropItem = options.DropTargetItem.Item;
    (dropItem as IFolderItem).IsDroppable(options.DraggedItems));

    If I drop inside everthing is fine. If I drop before (Telerik.Windows.Controls.DropPosition.
    Before) it seems that my dropItem I used for IsDroppable() is not the container where the RadTreeView drops my item. 

    An other trapdoor it that I have to check that I do not drag an Item in itself (drag A and drop it in A or drop in a child of A).

  2. Martin Ivanov
    Martin Ivanov avatar
    2360 posts

    Posted 22 Apr 2015 Link to this post

    Hi Koala,

    You can use the IsDropAllowed property of the RadTreeViewItem to disable the drop operation of the specific item. This approach is described in the Disable Drop at Specific Location help article. I also attached a sample project demonstrating such approach.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top