title: Get actual WPF Grid Width
body: <p>I have a WPF Window with a grid:</p>
  
  <pre><code>&lt;Grid Name="mainGrid"&gt;
    &lt;Grid.ColumnDefinitions&gt;
      &lt;ColumnDefinition Width="20*" /&gt;
      &lt;ColumnDefinition Width="700*" /&gt;
      &lt;ColumnDefinition Width="190*" /&gt;
    &lt;/Grid.ColumnDefinitions&gt;
    &lt;Grid.RowDefinitions&gt;
      &lt;RowDefinition Height="80" /&gt;
      &lt;RowDefinition Height="220*" /&gt;
      &lt;RowDefinition Height="450*" /&gt;
      &lt;RowDefinition Height="160*" /&gt;
      &lt;RowDefinition Height="30" /&gt;
    &lt;/Grid.RowDefinitions&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>In the codebehind, I am adding a stackpanel to the 1st column, 2nd row of mainGrid, but I am wanting the max width of the stackpanel to be the width of column 1 - 50px.  I stumbled accross <code>stkPanel.Width = mainGrid.ColumnDefinitions(1).Width.ToString - 50</code>, however this will error with:</p>
  
  <blockquote>
    <p>700* cannot be converted to double</p>
  </blockquote>
  
  <p>Is there a way to get the actual width of the grid column as it appears on the screen to use how I am wanting, or do I set padding or similar?</p>
  
  <p>Thanks,</p>
  
  <p>Matt</p>