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

Remove Drop Before/After

1 Answer 73 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
JDT
Top achievements
Rank 1
JDT asked on 31 May 2010, 03:21 PM
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. 

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 03 Jun 2010, 06:09 PM
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;
    }
    else
    {
        (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}"
    IsDragDropEnabled="True"
    Background="White"
    BorderThickness="1"
    BorderBrush="LightGray"
    Padding="16"
    PreviewDragEnded="radTreeView_PreviewDragEnded"
    IsDropPreviewLineEnabled="False"
    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.
Tags
TreeView
Asked by
JDT
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or