How to check the storyboard status?

How to check the storyboard status?

Example:

if (storyboard.Completed += true) // ???
{
}

(This code does not work for obvious reasons.)

+5
source share
4 answers

Just hook up the event Completed, and when your code runs there, the storyboard will be completed. See: http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.completed(VS.95).aspx#Y565

+4
source

How to create a boolean variable (e.g. IsCompleted) and set it to true in the Completed callback?

+4
source
if(storyboard.GetCurrentState() == ClockState.Active)
{
    // do something
}
+1

.

            Storyboard storyBoardPulse = this.FindResource("StoryboardMainIconPulse") as Storyboard;
            Storyboard.SetTarget(storyBoardPulse, this.imageIcon);

            if (storyBoardPulse.GetCurrentState() != ClockState.Active)
            {
                storyBoardPulse.Begin();
            }
Hide result

:

System.InvalidOperationException

HResult = -2146233079

Message = Unable to complete the action. The storyboard indicates does not apply to this object for interactive control.

Ao I am making a very bloody workaround:

private Boolean pulseOn;

private void operationsOfMaintenance_OperationExpired(Boolean state)
        {
            Storyboard storyBoardPulse = this.FindResource("StoryboardMainIconPulse") as Storyboard;
            Storyboard.SetTarget(storyBoardPulse, this.imageIcon);

            if (!state)
            {
                storyBoardPulse.Stop();
                storyBoardPulse.Remove();
                pulseOn = false;
            }
            else
            {
                if(!pulseOn)storyBoardPulse.Begin();
                pulseOn = true;
            }
        }
Run codeHide result

There anyboody knows why the first example gets an error!

thank

0
source

All Articles