Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
HTML
<usercontrol x:class="TreeViewDragDrop.MainPage" xmlns:x="#unknown">
    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" xmlns:local="#unknown" /> 
        <sdk:hierarchicaldatatemplate x:key="PeopleTemplate" itemssource="{Binding Children}" xmlns:sdk="#unknown"> 
            <textblock text="{Binding Name}" /> 
        </sdk:hierarchicaldatatemplate> 
    </usercontrol.resources> 
    <Canvas x:Name="LayoutRoot" DataContext="{StaticResource ViewModel}"> 
        <toolkit:treeviewdragdroptarget allowdrop="True" allowedsourceeffects="Copy,Move" xmlns:toolkit="#unknown"> 
            <sdk:treeview margin="0" width="250" itemssource="{Binding People}" itemtemplate="{StaticResource PeopleTemplate}" xmlns:sdk="#unknown" /> 
        </toolkit:treeviewdragdroptarget> 
        <sdk:treeview margin="270,0" width="200" itemssource="{Binding People}" allowdrop="True" itemtemplate="{StaticResource PeopleTemplate}" xmlns:sdk="#unknown" /> 
    </Canvas> 
</usercontrol>
Posted
Updated 23-Sep-15 2:39am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900