How would I 开发者_JAVA技巧check the status of a storyboard?
Example:
if (storyboard.Completed += true) // ???
{
}
(This code does not work, for obvious reasons.)
Just hook the Completed
event and when your code runs in there, the storyboard will have been completed. See: http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.completed(VS.95).aspx#Y565
how about creating a boolean variable (e.g. IsCompleted) and set it to true in the Completed callback?
This doesn't work.
Storyboard storyBoardPulse = this.FindResource("StoryboardMainIconPulse") as Storyboard;
Storyboard.SetTarget(storyBoardPulse, this.imageIcon);
if (storyBoardPulse.GetCurrentState() != ClockState.Active)
{
storyBoardPulse.Begin();
}
gets back this error:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=Impossible to execute the action. the Storyboard specify not applied to this object for interactive control.
Ao I make 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;
}
}
There's anyboody know why the first example gets an error!
thanks
if(storyboard.GetCurrentState() == ClockState.Active)
{
// do something
}
精彩评论