title: Pause rotation animation in WPF
body: <p>I have control with animation that rotates image.</p>
  
  <p>I want to start, pause and resume rotation animation at any moment.</p>
  
  <p>I have everything in behind code:</p>
  
  <pre><code>public partial class Wheel32Control : UserControl
      {
  
          public Wheel32Control()
          {
              InitializeComponent();
              img.RenderTransform = new RotateTransform();
              img.RenderTransformOrigin = new Point(0.5, 0.5);
  
              _daRotate = new DoubleAnimation(0, 360, TimeSpan.FromSeconds(2))
              {
                  RepeatBehavior = RepeatBehavior.Forever
              };
          }
  
          private DoubleAnimation _daRotate;
  
          private bool _rotate;
          public bool Rotate
          {
              get
              {
                  return _rotate;
              }
              set
              {
                  _rotate = value;
  
                  if (_rotate)
                      RotateStart();
                  else
                      RotateStop();
              }
          }
  
          private void RotateStart()
          {
              this.img.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, _daRotate);
          }
  
          private void RotateStop()
          {
              this.img.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
          }
      }
  </code></pre>
  
  <p>My XAML part:</p>
  
  <pre><code>&lt;Image Name="img" Source="/Plt;component/Resources/Images/Kolo_32_3.png"
             Stretch="None"/&gt;
  </code></pre>
  
  <p>My problem:</p>
  
  <p>When I stop animation - it "jumps" to "zero point". I want it to stop where it was when I stopped it.</p>
  
  <p>My code sets animation to "null" because I'm new in WPF and this is only way to stop animation I know.</p>