title: WPF: Org Chart TreeView Conditional Formatting
body: <p>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:  </p>
  
  <pre><code>         Alice
   ,--------|-------,------,------,
  Bob      Fred    Jack   Kim    Lucy
   |        |      
  Charlie  Greg    
  Darren   Henry
  Eric
  </code></pre>
  
  <p>As you can see it's not symmetrical, as Jack, Kim and Lucy report to Alice but have no reports of their own.  </p>
  
  <p>Using a <code>TreeView</code> with an <code>ItemsPanel</code> containing a <code>StackPanel</code> and <code>Orientation="Horizontal"</code> is <a href="http://www.codeproject.com/KB/WPF/CustomTreeViewLayout.aspx" rel="nofollow noreferrer">easy enough</a>, but this can result in a very large <code>TreeView</code> once some people have 20 others reporting to them! You can <a href="http://www.codeproject.com/KB/WPF/AdvancedCustomTreeViewLyt.aspx" rel="nofollow noreferrer">also use</a> <code>Triggers</code> to peek into whether a <code>TreeViewItem</code> has children with <code>Property="TreeViewItem.HasItems"</code>, but this is not in the same context as the before-mentioned <code>ItemsPanel</code>. <em>Eg: I can tell that Fred has reports, but not whether they have reports of their own.</em>  </p>
  
  <p>So, can you conditionally format <code>TreeViewItems</code> to be Vertical if they have no children of their own?</p>