title: Setting the RowDefinition Height from StaticResource
body: <p>In my WPF style I have defined a standard grid row height I'd like to apply to several places like so:</p>
  
  <pre><code>&lt;system:Double x:Key="TableRowHeight"&gt;22&lt;/system:Double&gt;
  </code></pre>
  
  <p>However it does not work when I'd like to apply this like so:</p>
  
  <pre><code>&lt;RowDefinition Height="{StaticResource TableRowHeight}"/&gt;
  </code></pre>
  
  <p>Instead I need to create a complete style like:</p>
  
  <pre><code>&lt;Style x:Key="GridTableRow" TargetType="{x:Type RowDefinition}"&gt;
      &lt;!--&lt;Setter Property="Height" Value="{StaticResource TableRowHeight}"/&gt;--&gt;
      &lt;Setter Property="Height" Value="22"/&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>As can be seen from the commented out line trying to reference the numeric constant within the Style definition does not work either, but the "hardcoded" value does.</p>
  
  <p>Now I've looked it up and I guess it is because the type associated with the Height property is GridLength and it somehow does not manage to automatically cast the double value when comming from another resource...</p>
  
  <p>The problem is that there does not seem to be a way of creating a GridLength object from XAML. The Value propery is readonly. So something like this does not work either:</p>
  
  <pre><code>&lt;Style x:Key="GridTableRow" TargetType="{x:Type RowDefinition}"&gt;
      &lt;Setter Property="Height"&gt;
          &lt;Setter.Value&gt;
              &lt;GridLength Value="{StaticResource TableRowHeight}"/&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Is there a way to get this to work, or should I just forget using that constant and just use the RowDefinition style with the hardcoded value in place of the constant?</p>