title: WPF DataGrid - Why the extra column
body: <p>I have a WPF app that uses <code>DataGrid</code> to display some data.  When I run the program there is an additional column as shown here:
  <img src="https://i.stack.imgur.com/nq36r.png" alt="enter image description here">   </p>
  
  <p>Here is what it looks like when I design it in VS2010<img src="https://i.stack.imgur.com/wi71B.png" alt="enter image description here"> </p>
  
  <p>I have turned off AutoGenerateColumns on the data grid and specified the columns individually as such (this is a user control):</p>
  
  <p></p>
  
  <pre><code>&lt;Grid Margin="10,10,10,10"&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto" /&gt;
          &lt;RowDefinition /&gt;
      &lt;/Grid.RowDefinitions&gt;
  
  
      &lt;DataGrid x:Name="EmployeeHours" AutoGenerateColumns="False" ItemsSource="{Binding EmployeeHoursLastWeek}" Width="Auto"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Header="PerceptionistID" Binding="{Binding PerceptionistID}" Width="100" /&gt;
              &lt;DataGridTextColumn Header="Week Of" Binding="{Binding WeekOf, StringFormat={}{0:MM/dd/yyyy}}" Width="75" /&gt;
              &lt;DataGridTextColumn Header="Regular Hours" Binding="{Binding WorkHours}" Width="100" /&gt;
              &lt;DataGridTextColumn Header="PTO Hours" Binding="{Binding PTOHours}" Width="100" /&gt;
              &lt;DataGridTextColumn Header="Holiday Hours" Binding="{Binding HolidayHours}" Width="100" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  
      &lt;Button x:Name="ImportHoursButton" Content="Import Hours" 
              Command="{Binding ImportHoursCommand}" 
              Height="25" Width="100" Margin="10"
              VerticalAlignment="Bottom" HorizontalAlignment="Right"                
              Grid.Row="1" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>I also have a MainWindowView that uses injection to display the views as such (this is a regular window):</p>
  
  <pre><code>&lt;Window x:Class="Sidekick.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:vm="clr-namespace:Sidekick.ViewModel"
          xmlns:vw="clr-namespace:Sidekick.View"
          Title="Sidekick"&gt;
  
      &lt;!-- Typically done in a resources dictionary --&gt;    
      &lt;Window.Resources&gt;
          &lt;DataTemplate DataType="{x:Type vm:EmployeeHoursViewModel}"&gt;
              &lt;vw:EmployeeHoursView /&gt;
          &lt;/DataTemplate&gt;
      &lt;/Window.Resources&gt;
  
      &lt;StackPanel&gt;
          &lt;ItemsControl ItemsSource="{Binding ViewModels}" Margin="3" /&gt;
      &lt;/StackPanel&gt;
  
  &lt;/Window&gt;
  </code></pre>
  
  <p>In the designer I have specified both MainWindowView and EmployeeHoursView as Auto Size root as I want the window to be just large enough to accommodate the grid and button.  However, when I run the program I get an additional column in the data grid and it makes the program window about twice as large (both width and height) as the EmployeeHoursView needs to be.  How can I code this such that my application window is just large enough for the EmployeeHoursView without providing specific values?  What is causing this additional column to appear?</p>