The following image demonstrates item "Child Item B1" (an item from the The following code has two TreeViewĬontrols and both TreeView has AllowDragItem, AllowDropItem and You must set the source's AllowDragItem and WhenĪ fixed sized data source is used, the item will always be copied since it can not be deletedĭrag and drop between two TreeView controls are very much identical to drag andĭrop within the same TreeView. Alternatively, you can use a fixed sized data source, such as a string array. Note item copy can only be performed if the items are populated from a data source.Ī TreeViewItem declared directly through XAML or created with code cannot beĬopied. This property is set to true, user can hold down the control key while drag and drop toĬopy an item. The default behavior for drag and drop an item is to move the item. The data source if you intend to enable drag and drop. When the underlying collection is changed, the TreeView mustīe notified so that it can updates its UI accordingly īecause of these two reasons, it is recommended that you use In that case the original item will not be moved For example, if the data source is a string array, then it can notĭelete an item. In order for such modification to succeed, the data source: Then when a TreeViewItem is being moved to a different location, the corresponding Underlying data source is an ObservableCollection object, In case the TreeView is populated from aĭata source, the underlying data source is modified. In this case when user drags and drops the item, the corresponding TreeViewItemĮlement is moved (it can not be copied). The above sample uses TreeViewItem statically declared in the XAML file.
A line is highlighted between the two target items to indicate The following image demonstrates dragging "Child Item 4" in between "Child Item 1"Īnd "Child Item 2".