views:

77

answers:

1

Why drag and drop doesnot work with my code:

   <toolkitDrag:TreeViewDragDropTarget AllowDrop="true" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" BindingValidationError="TreeViewDragDropTarget_BindingValidationError" ItemDroppedOnSource="TreeViewDragDropTarget_ItemDroppedOnSource" ItemDroppedOnTarget="TreeViewDragDropTarget_ItemDroppedOnTarget" ItemDragStarting="TreeViewDragDropTarget_ItemDragStarting">

       <controls:TreeView Name="treeView">

           <controls:TreeView.ItemTemplate>

               <toolkit:HierarchicalDataTemplate ItemsSource="{Binding Children}">

                  <StackPanel Orientation="Horizontal">

                       <TextBlock Text="{Binding Path=FullDescription}" />

                   </StackPanel>

               </toolkit:HierarchicalDataTemplate>

           </controls:TreeView.ItemTemplate>

       </controls:TreeView>

   </toolkitDrag:TreeViewDragDropTarget>

public OrganizationTree()

   {

       InitializeComponent();



       var organizationNodes=new List<OrganizationNode>();

       var firstNode = new OrganizationNode() { FullDescription = "Description" };

       firstNode.Children.Add(new OrganizationNode() { FullDescription = "desc1" });

       firstNode.Children.Add(new OrganizationNode() { FullDescription = "desc2" });

       firstNode.Children.Add(new OrganizationNode() { FullDescription = "desc3" });

       firstNode.Children.Add(new OrganizationNode() { FullDescription = "desc4" });

       organizationNodes.Add(firstNode);

       this.treeView.ItemsSource = organizationNodes;

   }

Can you give some information how to add drag and drop when itemsource set for treeview?

A: 

I changed List to ObservableCollection and everything become ok.

Evgeny