title: How can I pause a storyboard?
body: <p>This seems like it should be a no-brainer, but I can't get a WPF storyboard to pause. I call Pause and nothing happens -- it keeps right on animating.</p>
  
  <p>Here's a repro case: a button that animates its width. If you click the button, it calls Pause on the storyboard. I would expect that, as soon as I click the button, its width should stop changing; instead its width keeps right on animating as if I never called Pause.</p>
  
  <pre><code>NameScope.SetNameScope(this, new NameScope());
  var storyboard = new Storyboard();
  
  var button = new Button { Content = "Pause", Name = "pause" };
  this.Content = button;
  RegisterName(button.Name, button);
  var animation = new DoubleAnimation(0, 200, TimeSpan.FromSeconds(5));
  Storyboard.SetTargetName(animation, button.Name);
  Storyboard.SetTargetProperty(animation,
      new PropertyPath(FrameworkElement.WidthProperty));
  storyboard.Children.Add(animation);
  
  button.Click += (sender, e) =&gt; { storyboard.Pause(this); };
  storyboard.Begin(this);
  </code></pre>
  
  <p>From what I understand of the docs, I should call the <code>Pause(FrameworkElement)</code> overload with the same parameter I passed to <code>Begin</code>, hence the <code>Pause(this)</code> above. But I've also tried <code>storyboard.Pause()</code>, with no change in behavior. I also tried <code>storyboard.Pause(button)</code> just for the heck of it, again with no effect. I would have tried <code>storyboard.Pause(storyboard)</code> and <code>storyboard.Pause(animation)</code> just to exhaust the possibilities, but neither one compiles -- it wants a FrameworkElement (or FrameworkContentElement).</p>
  
  <p>How do I get the storyboad to pause?</p>