Search code examples
c#.netxamltreeviewhierarchicaldatatemplate

HierarchicalDataTemplate: first level of children only


I have a tree view of items, which currently shows all the levels of children, down to the furthest. How can I achieve to show only the first level of children? Is the HierarchicalDataTemplate the wrong approach, perhaps? Collapsing the children of level 2 and further would not be sufficent.


Solution

  • Well, without manipulating the data it's not possible to just show one level of children. The control would have needed a property, which is able to determine the deepness of shown nodes.

    This solution came to me and was quite obvious: I just use two flat tree views, the second one dependent on the SelectedItem of the first one. No HierarchicalDataTemplate needed, at all. Just a common DataTemplate.