This project is read-only.

How can i drag and drop treeview nodes?

Jul 19, 2010 at 12:33 PM

Why drag and drop doesnot work with my code:

 

 <Grid x:Name="LayoutRoot" Background="White">

       <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>

   </Grid>

 

 

 

 

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?