title: How do I get the actual resource from a ComponentResourceKey?
body: <p>I have a ComponentResourceKey defined in my resource dictionary like this:</p>
  
  <pre><code>&lt;Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:Resources}, ResourceId=BaseControlStyle}" TargetType="{x:Type FrameworkElement}"&gt;
      &lt;Setter Property="Margin" Value="4,4,0,0" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>I have a static class that I use as a shortcut to provide the resource keys liek this:</p>
  
  <pre><code>public class Resources
  {
      public static ComponentResourceKey BaseControlStyleKey
      {
          get
          {
              return new ComponentResourceKey(typeof(Resources), "BaseControlStyle");
          }
      }
  }
  </code></pre>
  
  <p>Now typically when I use this style I do something like this:</p>
  
  <pre><code>&lt;TextBlock Style="{DynamicResource {x:Static local:Resources.BaseControlStyleKey}}"/&gt;
  </code></pre>
  
  <p>However, I have a scenario where I need to set a style in code like this:</p>
  
  <pre><code>myTextBox.Style = Resources.BaseControlStyleKey // Does not work.
  </code></pre>
  
  <p>Any ideas how I extract the style from the ComponentResourceKey?</p>