title: DataGrid Setting the size of columns in code behind when the columns are auto generated
body: <p>I am auto generating my columns </p>
  
  <pre><code>&lt;DataGrid Grid.Row="0" AutoGenerateColumns="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="dataGrid1"   ItemsSource="{Binding Customers}" /&gt;
  </code></pre>
  
  <p>Now I want to set the size of each column in the code behind , to do something like this </p>
  
  <pre><code>&lt;DataGrid&gt;
    &lt;DataGrid.Columns&gt;
      &lt;DataGridTextColumn Width="Auto" /&gt;
      &lt;DataGridTextColumn Width="Auto" /&gt;
      &lt;DataGridTextColumn Width="*" /&gt;
    &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>I just want to attach to each column "Auto" , and to the last "*" , and everything in code behind.</p>
  
  <p>Thanks.</p>