title: Set Grid Column/Row width/Height dynamically
body: <p>I need to create a WPF grid dynamically from code behind. This is going okay and I can do it so that I set the content widths but what I need to do is set them so that when i resize the window the controls are re sized dynamically</p>
  
  <pre><code>var col = new ColumnDefinition();
  col.Width = new System.Windows.GridLength(200);
  grid1.ColumnDefinitions.Add(col);
  </code></pre>
  
  <p>This will produce XAML</p>
  
  <pre><code>&lt;Grid.ColumnDefinitions&gt;
       &lt;ColumnDefinition Width="200"&gt;&lt;/ColumnDefinition&gt;
  &lt;/Grid.ColumnDefinitions&gt;
  </code></pre>
  
  <p>But what I need is to use a * or question mark ie.</p>
  
  <pre><code>&lt;Grid.ColumnDefinitions&gt;
       &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
  &lt;/Grid.ColumnDefinitions&gt;
  </code></pre>
  
  <p>But the WidthValue does not support a * or question mark a when creating from code behind ?</p>