title: WPF DataGrid column widths and reordering
body: <p>I have a DataGrid defined as</p>
  
  <pre><code>&lt;wpftoolkit:DataGrid
          x:Name="AccountsDataGrid"
          AutoGenerateColumns="False"
          ItemsSource="{Binding Path=Accounts}"
          ColumnReordered="DataGrid_ColumnReordered"
          SelectionUnit="FullRow"
          RowHeaderWidth="0"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          &gt;
          &lt;wpftoolkit:DataGrid.Columns&gt;
              &lt;wpftoolkit:DataGridTextColumn Header="Account Id" Binding="{Binding Path=AccountId}" Width="Auto" /&gt;
              &lt;wpftoolkit:DataGridTextColumn Header="Account Name" Binding="{Binding Path=AccountName}" Width="*" /&gt;
          &lt;/wpftoolkit:DataGrid.Columns&gt;
      &lt;/wpftoolkit:DataGrid&gt;
  </code></pre>
  
  <p>which on load looks great. the first column fits to the minimum width necessary to fit both the content and the header. the second column stretches to fill the rest of the width of the DataGrid (so I don't have a 3rd filler column). But if I try to reorder the columns, the AccountName column cannot be resized to a width less than what its width was before the reorder. So I added a handler on the ColumnReordered event, figuring I can just reset the column widths, but it doesn't seem to work. In fact, it shrinks the AccountId column to almost nothing, and the AccountName column still cannot be resized smaller.</p>
  
  <pre><code>private void DataGrid_ColumnReordered(object sender, Microsoft.Windows.Controls.DataGridColumnEventArgs e)
      {
          foreach (DataGridColumn column in AccountsDataGrid.Columns)
          {
              if (column.Equals(AccountsDataGrid.Columns.Last()))
              {
                  column.Width = new DataGridLength(1.0, DataGridLengthUnitType.Star);
              }
              else
              {
                  column.Width = new DataGridLength(1.0, DataGridLengthUnitType.Auto);
              }
          }
      }
  </code></pre>
  
  <p>Is there a better way to handle the column widths and why does the column reordering break the column resizing ability</p>