【发布时间】:2014-03-12 01:33:20
【问题描述】:
我有 2 个触发事件,都带有 <Trigger.EnterActions> 和 <Trigger.ExitActions>,它们是 IsPressed 和 IsMouseOver。
当我点击一个按钮时,它将播放 <Trigger Property="IsPressed" Value="True"> 故事板:
<Trigger Property="IsPressed" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MouseDownTimeLine}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource MouseUpTimeLine}"/>
</Trigger.ExitActions>
</Trigger>
这是链接到这个故事板:
<Storyboard x:Key="MouseDownTimeLine" >
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity" >
<SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="MouseUpTimeLine">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity" >
<SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
不同的按钮也链接到同一个故事板。单击第二个按钮时,我希望它按原样播放情节提要,然后让第一个按钮返回正常状态。这是故事板的这一部分。
<Storyboard x:Key="MouseExitTimeLine">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Normal" Storyboard.TargetProperty="Opacity" >
<SplineDoubleKeyFrame KeyTime="00:00:00.00" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity" >
<SplineDoubleKeyFrame KeyTime="00:00:00.00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
当第二个按钮被点击时如何触发第一个按钮重置为正常
【问题讨论】:
标签: wpf xaml triggers storyboard wpf-animation