如何查看故事板的状态?
示例:
if (storyboard.Completed += true) // ???
{
}
(由于显而易见的原因,此代码 不起作用。)
答案 0 :(得分:4)
如何创建一个布尔变量(例如IsCompleted)并在Completed回调中将其设置为true?
答案 1 :(得分:4)
挂钩Completed
事件,当代码在那里运行时,故事板就会完成。请参阅:http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.completed(VS.95).aspx#Y565
答案 2 :(得分:1)
if(storyboard.GetCurrentState() == ClockState.Active)
{
// do something
}
答案 3 :(得分:0)
这不起作用。
Storyboard storyBoardPulse = this.FindResource("StoryboardMainIconPulse") as Storyboard;
Storyboard.SetTarget(storyBoardPulse, this.imageIcon);
if (storyBoardPulse.GetCurrentState() != ClockState.Active)
{
storyBoardPulse.Begin();
}

收回此错误:
System.InvalidOperationException未被用户代码
处理的HResult = -2146233079
消息=无法执行操作。故事板指定不 应用于此对象以进行交互式控制。
Ao我做了一个非常血腥的解决方法:
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;
}
}

有任何一个人都知道为什么第一个例子会出错!
谢谢