title: How to wrap WrapPanel children in a TreeView?
body: <p>I have a TreeView containing a parent and a couple of children. The children in turn consist of a WrapPanel with children of its own ("One", "Two", "Three" etc). How can I get these last elements to wrap when the parent window isn't large enough to accommodate them?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;TreeView ScrollViewer.HorizontalScrollBarVisibility="Disabled"&gt;
  
      &lt;TreeViewItem Header="Parent" IsExpanded="True" &gt;
  
          &lt;ItemsControl&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;WrapPanel Orientation="Horizontal"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.Items&gt;
                  &lt;TextBlock Text="One" /&gt;
                  &lt;TextBlock Text="Two" /&gt;
                  &lt;TextBlock Text="Three" /&gt;
                  &lt;TextBlock Text="Four" /&gt;
                  &lt;TextBlock Text="Five" /&gt;
                  &lt;TextBlock Text="Six" /&gt;
                  &lt;TextBlock Text="Seven" /&gt;
                  &lt;TextBlock Text="Eight" /&gt;
                  &lt;TextBlock Text="Nine" /&gt;
                  &lt;TextBlock Text="Ten" /&gt;
              &lt;/ItemsControl.Items&gt;
          &lt;/ItemsControl&gt;
  
          &lt;ItemsControl&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;WrapPanel Orientation="Horizontal"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.Items&gt;
                  &lt;TextBlock Text="One" /&gt;
                  &lt;TextBlock Text="Two" /&gt;
                  &lt;TextBlock Text="Three" /&gt;
                  &lt;TextBlock Text="Four" /&gt;
                  &lt;TextBlock Text="Five" /&gt;
                  &lt;TextBlock Text="Six" /&gt;
                  &lt;TextBlock Text="Seven" /&gt;
                  &lt;TextBlock Text="Eight" /&gt;
                  &lt;TextBlock Text="Nine" /&gt;
                  &lt;TextBlock Text="Ten" /&gt;
              &lt;/ItemsControl.Items&gt;
          &lt;/ItemsControl&gt;
  
      &lt;/TreeViewItem&gt;
  
  &lt;/TreeView&gt;
  </code></pre>
  
  <p>And here's what it currently produces:</p>
  
  <p><img src="https://i.stack.imgur.com/N7wrG.png" alt="enter image description here"></p>