Articles in this section
Category / Section

How to restrict dropping of a dragged TreeViewItemAdv over a target TreeViewItemAdv?

1 min read


DragEnd event alerts user when the dragged TreeViewItemAdv is about to drop over a target. The event arguments are TargetDropItem and AllowDragDrop.



It holds the instance of target drop TreeViewItemAdv.



Indicates whether the drop operation has to be allowed or not.

The following code example shows how to restrict dropping over a TreeViewItemAdv using DropEnd event and its arguments. This allows drop operation only on the first level items of TreeViewAdv.


<syncfusion:TreeViewAdv DragEnd="TreeViewAdv_DragEnd"  >
            <syncfusion:TreeViewItemAdv Header="Item 1">
                <syncfusion:TreeViewItemAdv Header="Item 1.1"/>
                <syncfusion:TreeViewItemAdv Header="Item 1.2"/>
            <syncfusion:TreeViewItemAdv Header="Item 2">
                <syncfusion:TreeViewItemAdv Header="Item 2.1">
                    <syncfusion:TreeViewItemAdv Header="Item 2.1.1"/>
                    <syncfusion:TreeViewItemAdv Header="Item 2.1.2"/>
                <syncfusion:TreeViewItemAdv Header="Item 2.2"/>
            <syncfusion:TreeViewItemAdv Header="Item 2"/>
            <syncfusion:TreeViewItemAdv Header="Item 3"/>            



private void TreeViewAdv_DragEnd(object sender, Syncfusion.Windows.Tools.Controls.DragTreeViewItemAdvEventArgs e)
            if (e.TargetDropItem is TreeViewItemAdv && (e.TargetDropItem as TreeViewItemAdv).ParentItemsControl != null && ((e.TargetDropItem as TreeViewItemAdv).ParentItemsControl is TreeViewItemAdv))
                e.AllowDragDrop = false;


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment