title: Accessing an element inside a UserControl resource
body: <p>I have a xaml file where I defined a <code>UserControl</code> with a <code>storyboard</code> as a resource this way:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
          &lt;Storyboard x:Key="RotateImage"&gt;
              &lt;DoubleAnimation x:Name="RotateImageAnimation" From="0" To="360" RepeatBehavior="Forever"  Duration="00:00:00.5" Storyboard.TargetName="rotateTransform" Storyboard.TargetProperty="Angle"/&gt;
          &lt;/Storyboard&gt;            
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>I'd like to access the RotateImageAnimation from the code behind, but if I write something like:</p>
  
  <pre><code>public void Foo(){
      RotateImageAnimation.To = 170;
  }
  </code></pre>
  
  <p>I get a runtime <code>NullPointerException</code>. How can I access the element within the resource? Thank you in advance.</p>