【问题标题】:WPF - Starting animation after another animation is finished in xamlWPF - 在 xaml 中完成另一个动画后开始动画
【发布时间】:2016-03-06 10:04:17
【问题描述】:

我正在使用 WPF,并且我有 2 个故事板动画。我希望第二个动画在第一个动画完成后开始。 如何在 xaml 代码中做到这一点?

【问题讨论】:

  • 你知道第一个动画的时长吗?如果您知道持续时间,那么您可以为第二个动画设置 BeginTime,使其在第一个动画之后开始。
  • 好主意,但它可能有更好的方法吗?

标签: wpf storyboard wpf-animation doubleanimation


【解决方案1】:

我不知道在 Xaml 中是否有可能,如果你可以在后面使用一些代码,你可以这样做:

 <Storyboard x:Name="MyStoryboard" Completed="MyStoryboardCompleted" FillBehavior="Stop">

在你的代码中

private void MyStoryboardCompleted(object sender, EventArgs e)
{
    var thing = this.FindResource("MyOtherStorboard");            
    var OtherSB = (Storyboard)thing;
    OtherSB.Begin();
}

【讨论】:

  • 是的,这是另一种方式,但不仅在 xaml 中。
猜你喜欢
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多