title: WPF Datagrid Column Width Issue
body: <p>I have columns in a <code>DataGrid</code> that are being set by an <code>ObservableCollection</code> that is the type of a simple data object that I created. The first column has a width set to "<strong>Auto</strong>" and the second column as a width set to "<strong>1*</strong>".</p>
  
  <p>I am currently using the method in the answer <a href="https://stackoverflow.com/questions/5549099/datagrid-column-width-doesnt-auto-update">here</a> to autoupdate the width of my column that is set to "Auto" when the <code>ItemsSource</code> changes. This seems to work most of the time:</p>
  
  <p><img src="https://i.stack.imgur.com/QFUDc.png" alt="enter image description here">
  <strong>This looks great, and works all of the time</strong></p>
  
  <p>Although, when the <code>ItemsSource</code> is a little bit larger (lets say about 30-35 records), the "Auto" width (first) column will shrink down <strong><em>only</em></strong> when the <code>DataGrid</code> (including the scroll bar) is <em>clicked</em>:</p>
  
  <p><img src="https://i.stack.imgur.com/Jyy7j.png" alt="enter image description here"> <strong>This will be resized properly if it hasn't been clicked</strong></p>
  
  <p>My XAML looks like this:</p>
  
  <pre><code> &lt;my:DataGrid CanUserSortColumns="false" CanUserResizeRows="false" CanUserResizeColumns="false" CanUserReorderColumns="false" CanUserDeleteRows="false" CanUserAddRows="false" AutoGenerateColumns ="False" SelectionMode="Single" SelectionUnit="Cell" Height="113" HorizontalAlignment="Left" Margin="11,22,0,0" Name="dataGrid" VerticalAlignment="Top" Width="226" Background="#FFE2E2E2" AlternatingRowBackground="#FFA4CFF2" BorderBrush="#FF7C7C7C" HorizontalGridLinesBrush="White" PreviewKeyDown="dataGrid_PreviewKeyDown" CellEditEnding="dataGrid_CellEditEnding" BeginningEdit="dataGrid_BeginningEdit" PreparingCellForEdit="dataGrid_PreparingCellForEdit" SelectedCellsChanged="dataGrid_SelectedCellsChanged" Loaded="dataGrid_Loaded" TargetUpdated="dataGrid_TargetUpdated"&gt;
          &lt;my:DataGrid.Columns&gt;
          &lt;my:DataGridTextColumn Binding="{Binding Path=Name, NotifyOnTargetUpdated=True}" Width="Auto"&gt;
                  &lt;my:DataGridTextColumn.CellStyle&gt;
                      &lt;Style TargetType="{x:Type my:DataGridCell}"&gt;
                          &lt;Setter Property="KeyboardNavigation.IsTabStop" Value="False"&gt;&lt;/Setter&gt;
                          &lt;Setter Property="IsHitTestVisible" Value="False"&gt;&lt;/Setter&gt;
                          &lt;Setter Property="Focusable" Value="False"&gt;&lt;/Setter&gt;
                          &lt;Setter Property="Background" Value="WhiteSmoke"&gt;&lt;/Setter&gt;
                          &lt;Setter Property="BorderBrush" Value="LightGray"&gt;&lt;/Setter&gt;
                      &lt;/Style&gt;
                   &lt;/my:DataGridTextColumn.CellStyle&gt;
                &lt;/my:DataGridTextColumn&gt;
          &lt;my:DataGridTextColumn Binding="{Binding Path=Value}" Width="1*"&gt;&lt;/my:DataGridTextColumn&gt;
     &lt;/my:DataGrid.Columns&gt;
   &lt;/my:DataGrid&gt;
  </code></pre>
  
  <p>The code to assure the updating of the column:</p>
  
  <pre><code> private void dataGrid_TargetUpdated(object sender, DataTransferEventArgs e)
      {
          dataGrid.Columns[0].Width = 0;
          dataGrid.UpdateLayout();
          dataGrid.Columns[0].Width = new DataGridLength(0, DataGridLengthUnitType.Auto);
          dataGrid.UpdateLayout();
      }
  </code></pre>
  
  <p>Is there any reason this may be happening only when the list is longer like this?</p>