title: How can you tell if a specific storyboard is currently active on an element?
body: <p>We have a storyboard that we use to indicate a valid value has been typed into a <code>TextBox</code>.  Specifically, it sets the background to green, then fades it to light green, then holds there.  If the value doesn't pass, then we remove the storyboard</p>
  
  <p>Here's pseudocode we run when the text changes...</p>
  
  <pre><code>if(testPassed)
      PassedAnimationWithHold.Begin(TestTextBox, true);
  else // &lt;-- We need a condition here to determine if we actually should remove it or not
      PassedAnimationWithHold.Remove(TestTextBox);
  </code></pre>
  
  <p>The issue is if they start typing invalid characters from the beginning, the code above tries to remove a storyboard that hasn't been applied yet.</p>
  
  <p>Short of adding our own boolean flag, is there a way we can test to see if that storyboard is active on our element?</p>
  
  <h2>Update</h2>
  
  <p>@sa_ddam213's answer below seems to be leading in the right direction, but as I called out in the comments, that depends on knowledge of (one of) the ultimate target(s) of the storyboard as well as the property being animated.</p>
  
  <p>For instance, consider our actual storyboard which, when applied to a control, pulses its background light green, then fades back to the pre-animated background color (Note: It is understood we only apply this to objects who have specified a SolidColorBrush for their background, or else this of course would fail as not all brushes have a 'Color' property.)</p>
  
  <pre><code>&lt;Storyboard x:Key="{x:Static gr:Storyboards.PassedPulseKey}"
      Storyboard.TargetProperty="Background.Color"&gt;
  
      &lt;ColorAnimation
          From="#F8F8"
          Duration="{StaticResource {x:Static gr:Storyboards.PulseDurationKey}}"
          FillBehavior="Stop" /&gt;
  
  &lt;/Storyboard&gt;
  </code></pre>
  
  <p>So in order to use his technique, we somehow need to be able to check IsAnimated on the ValueSource of the Color property on the SolidColorBrush stored in the storyboard-applied-to object's Background property.  That's where I hit another wall.</p>
  
  <p>I'm starting to think its better if I use a style with triggers to apply the storyboard instead of via code, then just let the WPF system take care of it.  That would mean I would have to add a 'Passed' property to our ViewModel to bind the trigger to though.  Still, it can be done!</p>