I am trying to get a view of my tree to group a collection of similar elements as they are. To preserve a common property, my object hierarchy might look like this:
- The objects
- Group of objects # 1
- Item # 1 (Type 'A')
- Item # 2 (Type 'A')
- Item No. 3 (type 'B')
- Item # 4 (Type 'B')
Right now, my TreeView shows these objects in exactly the same way as the object model, but I would like to add a TreeView node for each type of object so that it looks like this:
In a similar question, I saw that someone recommended having two separate HierarchicalDataTemplates , so I created one for the Object Group # 1 level, which contains a TreeView with a list of types, but this is really awkward, because it is a separate separate TreeView inside some nodes . I am also trying to use CollectionViewSource to filter out items in each category, but this is not very useful as I cannot figure out how to display them.
I think my question boils down to the following: how to make the HierarchicalDataTemplate group its children? If someone could point me in the right direction, I would really appreciate it.
I can post some code if someone wants to see it, but I'm just trying to figure out how to do what I want, so my code is just a direct tree-like tree-like direct image.
c # wpf xaml treeview hierarchicaldatatemplate
aalex675
source share