gpt4 book ai didi

c# - C#中的动画触发器( Storyboard+触发器)

转载 作者:太空宇宙 更新时间:2023-11-03 15:39:33 25 4
gpt4 key购买 nike

我有一个使用 DoubleAnimationUsingKeyFrames 的动画,我需要使用触发器打开动画的第一部分。我该怎么做?

 <Storyboard x:Key="TargetStoryboard">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TargetArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:0.0000000" Value="0.001"/>
<SplineDoubleKeyFrame KeyTime="00:00:0.6000000" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:3.6000000" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:4.3000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>

<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TargetArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:0.0000000" Value="-60"/>
<SplineDoubleKeyFrame KeyTime="00:00:0.6000000" Value="-222"/>
<SplineDoubleKeyFrame KeyTime="00:00:3.6000000" Value="-222"/>
<SplineDoubleKeyFrame KeyTime="00:00:4.8000000" Value="3.35"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>

它一定是这样的,但它不起作用。

<Storyboard x:Key="TargetStoryboard">
<Trigger Property="dAnimTrigger" Value="True">
<Trigger.EnterActions>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TargetArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:0.0000000" Value="0.001"/>
<SplineDoubleKeyFrame KeyTime="00:00:0.6000000" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:3.6000000" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:4.3000000" Value="0"/>

</DoubleAnimationUsingKeyFrames>
</Trigger.EnterActions>
</Trigger>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TargetArea" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:0.0000000" Value="-60"/>
<SplineDoubleKeyFrame KeyTime="00:00:0.6000000" Value="-222"/>
<SplineDoubleKeyFrame KeyTime="00:00:3.6000000" Value="-222"/>
<SplineDoubleKeyFrame KeyTime="00:00:4.8000000" Value="3.35"/>

</DoubleAnimationUsingKeyFrames>

</Storyboard>

请帮我解决这个问题。

最佳答案

在 EnterActions 和 ExitActions 中使用 beginstoryboard 更改触发器

请查看以下代码:

<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="1" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.25" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>

关于c# - C#中的动画触发器( Storyboard+触发器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30712210/

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