gpt4 book ai didi

c# - 可重复使用的动画

转载 作者:太空狗 更新时间:2023-10-29 20:39:17 25 4
gpt4 key购买 nike

我是 WPF 和 XAML 的新手。

我为文本框创建了一个简单的淡入淡出动画:-

<Storyboard x:Key="storyFadeInOutTop" Name="storyFadeInOutTop">
<DoubleAnimation From="0" To="1" Duration="00:00:01"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
<DoubleAnimation From="10" To="0" Duration="00:00:01" BeginTime="00:00:01"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="0" To="10" Duration="00:00:01" BeginTime="00:00:05"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="1" To="0" Duration="00:00:01" BeginTime="00:00:06"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
</Storyboard>

我想做的是在动画的生命周期内多次运行这个 Storyboard。

类似的东西:-

<Storyboard>
<!-- (Run my fade-in-fade out with BeginTime of 00:00:00) -->
<StringAnimationUsingKeyFrames Duration="00:00:01" BeginTime="00:00:07"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Text">
<DiscreteStringKeyFrame Value="Game design and concept by" KeyTime="0:0:1" />
</StringAnimationUsingKeyFrames>
<!-- (Run my fade-in-fade out again with BeginTime of 00:00:07) -->
<StringAnimationUsingKeyFrames Duration="00:00:01" BeginTime="00:00:07"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Text">
<DiscreteStringKeyFrame Value="Look Ive changed to another credit" KeyTime="0:0:1" />
</StringAnimationUsingKeyFrames>
<!-- (etc etc) -->
</Storyboard>

我希望您理解我正在尝试做的事情的要点。我知道我可以将 Storyboard 中的代码添加到上面的每个部分,但这会非常乏味。有没有一种优雅的方式来做到这一点?

最佳答案

您应该能够在 Storyboard上设置 RepeatBehavior 属性 (inherited from Timeline)

<Storyboard x:Key="storyFadeInOutTop" Name="storyFadeInOutTop" RepeatBehavior="Forever">
<DoubleAnimation From="0" To="1" Duration="00:00:01"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
<DoubleAnimation From="10" To="0" Duration="00:00:01" BeginTime="00:00:01"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="0" To="10" Duration="00:00:01" BeginTime="00:00:05"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="1" To="0" Duration="00:00:01" BeginTime="00:00:06"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
</Storyboard>

RepeatBehavior 也可以设置为正整数。

关于c# - 可重复使用的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26159445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com