Remove Drop Before/After

2 posts, 0 answers
  1. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 31 May 2010 Link to this post

    Hi Telerik,

    I have a treeview that can drag and drop items within the treeview. This works great. However when I drag from a GridView to a Treeview, I only want those items to be dropped in a treeview item, not before/after as a treeview item. For this scenario how can I disable showing/allowing the drop before and after?

    Also when these gridview items are dropped in a treeviewitem I don't want them to become new nodes on the tree, just handled.

    Thanks! Appreciate it. 
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 03 Jun 2010 Link to this post

    Hi JDT,

    Please accept my apology for the delayed response.

    You can handle the OnDragInfo() event of for RadTreeView and hide the DragTooltip if the DropPosition isn't Inside:
    private void OnDropInfo(object sender, DragDropEventArgs e)
        RadTreeViewItem destItem = e.Options.Destination as RadTreeViewItem;
        if (destItem != null && destItem.DropPosition != DropPosition.Inside)
            (e.Options.DragCue as TreeViewDragCue).DragTooltipVisibility = Visibility.Collapsed;
            (e.Options.DragCue as TreeViewDragCue).DragTooltipVisibility = Visibility.Visible;
    Also you can set the IsDropPreviewLineEnabled property of the RadTreeView to false in the declaration of the control:
    <telerikNavigation:RadTreeView x:Name="radTreeView"
        ItemTemplateSelector="{StaticResource ExampleTemplateSelector}"
        VerticalAlignment="Top" HorizontalAlignment="Left"/>

    You can find more information about the DragAndDrop feature of the RadTreeView here.

    Also if you need to deny dropping of items in certain positions, you can handle the PreviewDragEnded() event:
    private void radTreeView_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
        //deny dropping of the dragged items
        e.Handled = true;
    You can check here if the e.DropPosition is Inside, Before or After and implement some custom logic.

    Please take a look at the attached project and let me know if this is what you had in mind or if you need more info.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top