私はUWPを使ってC#でシンプルなティックタックトーを作ることに取り組んでいます。状態に応じてボタンのノーマル/ホバー外観が異なるようにする
マウスをセルの上に置くと、シンボルのゴーストが表示されるように、いくつかのエフェクトを追加したいと思います。しかし、シンボルがすでに配置されている場合は、シンボルをわずかに消す必要があります。
これを達成するにはどうすればよいでしょうか?所望の効果の
例:
トップセンターは、マウスではない上、シンボルに配置されます。
センターがシンボル配置されている、マウスオーバー。
センター右はシンボルが配置されていない、マウスオーバーしています。
他のセルはシンボルが配置されていない、マウスは上に配置されていません。
現在、私のような定義されたControlTemplateがあります。そして、
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="NormalSolid" >
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerIcon">
<EasingDoubleKeyFrame KeyTime="0" Value="0.75"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOverSolid">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerIcon">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.75"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal" >
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerIcon">
<EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PlayerIcon">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.25"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
を、それはそうのように変更されます。GameButtonは簡単なサブクラスである
private void GameButton_PointerExited(object sender, PointerRoutedEventArgs e)
{
GameButton button = sender as GameButton;
VisualStateManager.GoToState(button, "Normal" + (!this.ShapePlaced ? "" : "Solid"), true);
}
private void GameButton_PointerEntered(object sender, PointerRoutedEventArgs e)
{
GameButton button = sender as GameButton;
VisualStateManager.GoToState(button, "PointerOver" + (!this.ShapePlaced ? "" : "Solid"), true);
}
(ボタン、PlayerIconは描画される形状を表す形状)
しかし、これは、ボタンの周りをクリック+ドラッグすることに問題があり、信頼性がありません。異なるVisualStateGroupに2組の状態(配置されていない状態と配置されていない状態)を配置し、現在の状態に応じて「アクティブ」グループを切り替えることは可能でしょうか?
基本的には、2つの標準状態、2つのPointerOver状態、およびそれらを切り替える方法が必要です。
こんにちは、お返事いただきありがとうございます。ウェブを見ると、私はあなたがそれを行うことができることを知りました。しかし、シェイプが配置されているかどうかによって、切り替えることができる2つの異なる "Normal"と "PointerOver"の状態が本質的に必要なので、私の場合はどのように使用しますか?ありがとう。 – minerz029