开发者

Silverlight toolkit. Treeview drag and drop functionality

Drag and drop does not work with this snapshot:

开发者_运维知识库   <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;

   }

Suppose to work out of the box. Any ideas what can be wrong?


I have changed the List to ObservableCollection and drag and drop is working fine now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜