title: Restarting a WPF Storyboard
body: <p>What is the proper way to stop and restart a storyboard from .net code?</p>
  
  <p>I'm trying ...</p>
  
  <pre><code>myStory.Stop(this);
  </code></pre>
  
  <p>Expecting that a subsequent call to .Begin(this); would restart from the timeline at zero, but instead, the storyboard picks up right where it was stopped.</p>
  
  <p>I have tried </p>
  
  <pre><code>.Remove(this);
  </code></pre>
  
  <p>and I tried </p>
  
  <pre><code>.Seek(TimeSpan.Zero); 
  </code></pre>
  
  <p>which also didn't work.</p>
  
  <p>More details ... Here is my storyboard sample.</p>
  
  <pre><code>&lt;Storyboard x:Key="overlay"&gt;
      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textone" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="0"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="1"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="1"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="0"/&gt;
      &lt;/DoubleAnimationUsingKeyFrames&gt;
      &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="texttwo" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="0"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="1"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="1"/&gt;
          &lt;SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="0"/&gt;
      &lt;/DoubleAnimationUsingKeyFrames&gt;
  &lt;/Storyboard&gt;
  </code></pre>
  
  <p>So the text in the textone runs, and if you close the screen, and return to the screen quickly, the texttwo, actually plays over a newly started storyboard. So the original (from the first screen) storyboard is still around and playing, even though I've removed, and stopped it.</p>