在WinRT / c中以编程方式设置时,BeginTime无法正常工作#

时间:2012-11-06 13:25:27

标签: c# xaml animation storyboard

我正在通过代码隐藏在我的Windows 8应用程序中的动画。我有一组动画对象,每个对象包含一个DoubleAnimation。我调用一个迭代这个集合的方法,为每个集合创建新的Storyboard对象并开始它们。无论我是在故事板上设置BeginTimeDoubleAnimation还是两者,它们都会同时启动和运行。

如何将动画延迟一定的毫秒数?

  foreach (AnimationObject a in queue)
  {
      Storyboard sb = new Storyboard();
      sb.Duration = a.DoubleAnimation.Duration;
      sb.BeginTime = a.DoubleAnimation.BeginTime;
      sb.Children.Add(a.DoubleAnimation);
      Storyboard.SetTarget(a.DoubleAnimation, a.Target);
      Storyboard.SetTargetProperty(a.animation, a.TargetProperty);
      sb.Begin();
  }

我编写了一个使用await Task.Delay(a.BeginTime)的队列而且这个有效,所以我知道我正在设置BeginTime。然而,任务延迟方法看起来效率不高

1 个答案:

答案 0 :(得分:0)

我的问题是,后来针对相同Storyboard {{}}}的Target覆盖了之前的DoubleAnimationUsingKeyFrames。我重新设计了我的队列以使用Storyboard,然后将关键帧添加到现有的{{1}}。一切都完美了!

相关问题