[英]Animation Trigger (Storyboard + Trigger) in C#
我有一個使用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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.