![]() ![]() However, if this condition is too difficult, it may be acceptable to allow this after all.įinally, I don't want the ability to drag Buildings at all. The same goes for Persons - I should not be able to drag a Person from Room 1.01 to Room 1.02. I also do like the ability to drag one Office to another Team, it should only be possible to drag Offices within their original parent Team. I do not want the ability to drag an Office into another Office, or a Person into a Team, or something "impossible" like that. And I want to change the order of the Persons within a single Office. At the same time, I also want to be able to change the order of the Offices within a single Team. ![]() Now I want to be able to change the order of the Teams by dragging them. ![]() So the hierarchy is Team -> Office -> Person. A Team further consists of a list of Offices (or rooms), and an Office finally has multiple Persons. The TreeView is showing a list of Teams, and a list of Buildings (not important). Furthermore, I want to enable dragging for all of the child levels, but again only within their own parent. The dragging should only ever cause a re-ordering of the items, it should not be able to drop inside of a child or inside of a different parent (as in the Treeview example). The TreeView has multiple levels and multiple root nodes, and I only want to implement the dragging for one of the root nodes (the others should not support dragging at all). Because the data is recursive, the HierarchicalDataTemplate can be applied to each level.I am trying to implement a simple "drag to re-order" functionality for my TreeView. Each Employee element can contain other Employee elements to indicate who reports to whom. The TreeView binds to XML data that represents the employees in a company. The following example demonstrates how to bind a TreeView to hierarchical data and use a HierarchicalDataTemplate to specify the ItemsSource for each TreeViewItem. ![]() By using a HierarchicalDataTemplate, you can recursively set the ItemsSource for each TreeViewItem in the TreeView. When you set the HierarchicalDataTemplate.ItemsSource property, that value is used when the HierarchicalDataTemplate is applied. The HierarchicalDataTemplate enables you to specify the ItemsSource for a TreeViewItem, or any HeaderedItemsControl, on the data template. For example, if you set the ItemTemplate property on a data-bound TreeView, each TreeViewItem that is generated uses the DataTemplate that was assigned to the ItemTemplate property of the TreeView. When you set the ItemsControl.ItemTemplate property and if the ItemsControl generates an ItemsControl for each child item, then the child ItemsControl uses the same ItemTemplate as the parent. If the data is represented in a way that is not hierarchical, you must build a hierarchical representation of the data. For example, an Employee class might contain a collection of Employee objects that are the direct reports of an employee. The data source must have a hierarchical object model. This can occur when the data is recursive in nature, such as a file system, where folders can contain folders, or a company's organizational structure, where employees have other employees as direct reports. There might be times when you want to bind a TreeView to a data source whose depth is not known. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |