title: WPF - Usercontrol as ListItemTemplate not filling listbox width
body: <p>Just trying to get my head round WPF. I have a usercontrol which I'm using as the template for items in a listbox, however no matter what I try the usercontrol's width is always shrinking to the minimum size but I want it to fill the available width. I've found a similar query on here but it was relating just to a usercontrol not within a listbox and the solution proposed doesn't apply here.</p>
  
  <p>My UserControl is defined as :</p>
  
  <pre><code>&lt;UserControl x:Class="uReportItem"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
           d:DesignHeight="60" d:DesignWidth="300"&gt;
  &lt;Grid &gt;
      &lt;Border CornerRadius="3,3,3,3" BorderBrush="#0074BA" BorderThickness="1" Background="#00D6F9" Margin="0"&gt;
          &lt;DockPanel Margin="3,3,3,3"&gt;
              &lt;Grid Height="Auto"&gt;
                  &lt;!-- Grid Definition--&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                      &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
  
                  &lt;!-- Content --&gt;
  
                  &lt;!-- Top Row--&gt;
                  &lt;Button Grid.RowSpan="2"&gt;Delete&lt;/Button&gt;
                  &lt;StackPanel Orientation="Horizontal" Grid.Column="1"&gt;
                      &lt;Label x:Name="Heading" Content="{Binding Heading}" FontSize="14" FontWeight="bold"&gt;&lt;/Label&gt;
                      &lt;Label x:Name="Subheading" Content="{Binding SubHeading}" FontSize="14"&gt;&lt;/Label&gt;
                  &lt;/StackPanel&gt;
                  &lt;Button Grid.Column="2"&gt;Blah&lt;/Button&gt;
  
  
                  &lt;!-- Second Row--&gt;
                  &lt;Label Grid.Row="1" Grid.Column="1" x:Name="Comments"&gt;Comments&lt;/Label&gt;
                  &lt;Button Grid.Column="2"&gt;Blah&lt;/Button&gt;
              &lt;/Grid&gt;
          &lt;/DockPanel&gt;
      &lt;/Border&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the implementation on the window is :</p>
  
  <pre><code>&lt;Window x:Class="vReport"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:RecorderUI"
  Title="vReport" Height="300" Width="300" Background="#00BCF0"&gt;
  
  &lt;Window.Resources&gt;
      &lt;DataTemplate x:Key="Record" DataType="ListItem"&gt;
          &lt;Grid&gt;
              &lt;local:uReportItem&gt;&lt;/local:uReportItem&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
      &lt;Style TargetType="ListBoxItem"&gt;
          &lt;Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;local:uReport Margin="5" Grid.Row="0"&gt;&lt;/local:uReport&gt;
  
      &lt;Border Grid.Row="1" BorderBrush="#0074BA" CornerRadius="3"&gt;
          &lt;ListBox Margin="5" Background="#00D6F9" BorderBrush="#0074BA" x:Name="ListRecords" ItemsSource="{Binding Items}" ItemTemplate ="{StaticResource Record}"&gt;&lt;/ListBox&gt;
      &lt;/Border&gt;
  
      &lt;TextBlock Grid.Row="2" x:Name="SelectedItem" Text="{Binding Path=SelectedItem.Heading, Mode=TwoWay}"&gt;&lt;/TextBlock&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any ideas?</p>