I have a TreeView controll with it's ItemsSource bound to an ObservableCollection of my ViewModel. I have the TreeView wrapped by a TreeViewDragDropTarget, so that users can move nodes of the tree around, ala Windows Explorer.
I have the TreeViewDragDropTarget AllowedSourceEffects set to Copy, Move.
Howerver regardless of the user executing a copy action (drag with CTRL press) the action remains a Move. The ObservableCollection CollectionChanged events fire, first with a Remove and then an Add. What I would have hoped for is just the Add.
Here's the Xmal. What am I missing?
<UserControl x:Class="TreeViewDragDrop.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TreeViewDragDrop"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="800" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
<UserControl.Resources>
<local:MainPageViewModel x:Key="ViewModel"/>
<sdk:HierarchicalDataTemplate x:Key="PeopleTemplate" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}"/>
</sdk:HierarchicalDataTemplate>
</UserControl.Resources>
<Canvas x:Name="LayoutRoot" DataContext="{StaticResource ViewModel}">
<toolkit:TreeViewDragDropTarget AllowDrop="True" AllowedSourceEffects="Copy,Move" >
<sdk:TreeView Margin="0" Width="250" ItemsSource="{Binding People}" ItemTemplate="{StaticResource PeopleTemplate}"/>
</toolkit:TreeViewDragDropTarget>
<sdk:TreeView Margin="270,0" Width="200" ItemsSource="{Binding People}" AllowDrop="True" ItemTemplate="{StaticResource PeopleTemplate}"/>
</Canvas>
</UserControl>