title: How do I make an ItemsControl stretch to fill all available space?
body: <p>I have an ItemsControl, with its ItemsSource bound to a list of items. The size of each of the items is as small as they can be, what I need is for the control and the items in the control to stretch to fit all available space. </p>
  
  <p>I tried setting VerticalAlignment to Stretch on both the control, and its items (using a style). I also tried wrapping the ItemsControl in a DockPanel, and docking the ItemsControl to the bottom. How do I have the ItemsControl dynamically resize?</p>
  
  <p>Also some, but not all, of the item's visibilities are set to Collapsed (through the same style). Will that be a factor in how this needs to be done?</p>
  
  <pre><code>&lt;DockPanel HorizontalAlignment="Stretch"&gt;
      &lt;ItemsControl DockPanel.Dock="Bottom"
                      ItemsSource="{Binding Owner.LoadPointCharts}"
                      HorizontalAlignment="Stretch"
                      x:Name="ItemsControl"&gt;
          &lt;ItemsControl.ItemContainerStyle&gt;&lt;!--Height="{Binding Path=Height, RelativeSource={RelativeSource AncestorType={x:Type DockPanel}}}"--&gt;
              &lt;Style TargetType="ContentPresenter"&gt;
              &lt;Setter Property="VerticalAlignment"
                      Value="Stretch" /&gt;
  
                  &lt;Setter Property="Visibility"&gt;
                  &lt;Setter.Value&gt;
                      &lt;MultiBinding Converter="{StaticResource CompareIndexToVisibilityConverter}"&gt;
                          &lt;Binding Path="Index" /&gt;
                          &lt;Binding Path="SelectedIndex" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
              &lt;/Style &gt;
          &lt;/ItemsControl.ItemContainerStyle&gt;
          &lt;/ItemsControl&gt;
  &lt;/DockPanel&gt; 
  </code></pre>