The company has the traditional complex organizational structure, defining the amount of levels using the letter ‘n’ rather than an actual number. I will try and express the structure I’m trying to achieve in mono-spaced font:
Alice ,--------|-------,------,------, Bob Fred Jack Kim Lucy | | Charlie Greg Darren Henry Eric
As you can see it’s not symmetrical, as Jack, Kim and Lucy report to Alice but have no reports of their own.
Using a TreeView with an ItemsPanel containing a StackPanel and Orientation='Horizontal' is easy enough, but this can result in a very large TreeView once some people have 20 others reporting to them! You can also use Triggers to peek into whether a TreeViewItem has children with Property='TreeViewItem.HasItems', but this is not in the same context as the before-mentioned ItemsPanel. Eg: I can tell that Fred has reports, but not whether they have reports of their own.
So, can you conditionally format TreeViewItems to be Vertical if they have no children of their own?
I did end up using tips from the linked article, which I’d already read through but didn’t think would help me.
The meat of it happens here, in a converter:
Which in turn gets consumed in a style I created for the TreeView: