title: WPF: WrapPanel in ItemsPanelTemplate expands list width
body: <p>I have a listbox defined like this:</p>
  
  <p>
          
              
                  
              
          </p>
  
  <pre><code>    &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ItemsControl&gt;
                  &lt;!-- Contents here --&gt;
              &lt;/ItemsControl&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>My problem is this: This list is contained in a grid control, and should use all the available space of that cell its contained in, but it shouldn't force the parent to allocate MORE space. But what happens is that once the wrap panel fills up, instead of actually wrapping the items to the next line (as it should), it just expands the width of the listbox, and in the process forces the parent grid to resize as well.</p>
  
  <p>How can I get the wrap panel to respect the size of its parent, and not force it to expand its size?</p>
  
  <p>Thanks in advance!</p>
  
  <p>edit: One more thing. I can set the width of the wrappanel explicitly to make it wrap, but I would like the wrappanel to have the same size as the listbox.</p>