0

私は 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 にリンクされています。2番目のボタンをクリックすると、ストーリーボードを再生したいのですが、最初のボタンは通常の状態に戻ります。ストーリーボードのこの部分です。

<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>

2番目のボタンがクリックされたときに、最初のボタンをトリガーして通常にリセットするにはどうすればよいですか

4

1 に答える 1

1

ここで間違っているかもしれませんが、ボタン テンプレートにラジオ ボタン機能が組み込まれているようです。ボタンをクリックすると、「クリック」(またはチェック)されたままになり、別のボタンをクリックすると、最初のボタンからのクリックが「解放」されます。

テンプレートのターゲット タイプを次のように変更しRadioButton、トリガーを次のように変更します。

<Trigger Property="IsChecked" Value="True">
   <Trigger.EnterActions>
       <BeginStoryboard x:Name="ButtonCheckedStoryboardBegin"
                        Storyboard="{StaticResource MouseDownTimeLine}"/>
   </Trigger.EnterActions>
   <Trigger.ExitActions>
       <StopStoryboard BeginStoryboardName="ButtonCheckedStoryboardBegin"/>
   </Trigger.ExitActions>
</Trigger>

StopStoryboardMouseExitTimeLine の期間がゼロであるため使用します。終了アニメーションに実際に時間が必要な場合は、次を使用します。

<Trigger Property="IsChecked" Value="True">
   <Trigger.EnterActions>
       <BeginStoryboard Storyboard="{StaticResource MouseDownTimeLine}"/>
   </Trigger.EnterActions>
   <Trigger.ExitActions>
       <BeginStoryboard Storyboard="{StaticResource MouseExitTimeLine}"/>
   </Trigger.ExitActions>
</Trigger>

[2番目のオプションはそのまま使用できます-期間はゼロですが、エレガントではありません、IMO]

また、MouseDownTimeLine は "Hover" に何も設定していないため、MouseExitTimeLine の "Hover" のアニメーションは冗長であり、削除できます。

RadioButtonここで、レイアウト内の各インスタンスに を追加しGroupName="<Some string here>"ます。任意の時点で、グループ内の 1 つのラジオ ボタンのみをオンにできます。

于 2014-02-13T23:55:07.620 に答える