我有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>
當第二個按鈕被點擊我怎麼觸發的第一個按鈕復位到正常
當我將模板更改爲RadioButton時,出現大量錯誤。 RadioButton ControlTemplate TargetType與模板類型Button不匹配? – Ben
您需要將'Button'的實例更改爲'RadioButton'。 – XAMeLi