【发布时间】:2015-06-08 14:42:24
【问题描述】:
我有一个使用 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>
请帮我解决这个问题。
【问题讨论】:
-
您已经很接近了,只是缺少
<BeginStoryboard>和<Storyboard>,如果您快速查看some docs,您会很快看到您丢失的部分。 PS,喜欢这个用户名,因为他是一个偶像。干杯。
标签: c# wpf xaml animation triggers