VisualState クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コントロールが特定の状態のときの外観を表します。
public ref class VisualState : System::Windows::DependencyObject
[System.Windows.Markup.ContentProperty("Storyboard")]
[System.Windows.Markup.RuntimeNameProperty("Name")]
public class VisualState : System.Windows.DependencyObject
[<System.Windows.Markup.ContentProperty("Storyboard")>]
[<System.Windows.Markup.RuntimeNameProperty("Name")>]
type VisualState = class
inherit DependencyObject
Public Class VisualState
Inherits DependencyObject
- 継承
- 属性
例
次の例では、呼び出された CommonStates
の Button 内に ControlTemplate をVisualStateGroup作成し、状態、Pressed
Normal
および のオブジェクトを追加VisualStateしますMouseOver
。 Buttonでは、 内にある というDisabled
CommonStates
VisualStateGroup状態も定義されていますが、簡潔にするために省略しています。 例全体については、「 ControlTemplate を作成して既存のコントロールの外観をカスタマイズする」を参照してください。
<!--Define the states and transitions for the common states.
The states in the VisualStateGroup are mutually exclusive to
each other.-->
<VisualStateGroup x:Name="CommonStates">
<!--The Normal state is the state the button is in
when it is not in another state from this VisualStateGroup.-->
<VisualState x:Name="Normal" />
<!--Change the SolidColorBrush, BorderBrush, to red when the
mouse is over the button.-->
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BorderBrush"
Storyboard.TargetProperty="Color"
To="Red" />
</Storyboard>
</VisualState>
<!--Change the SolidColorBrush, BorderBrush, to Transparent when the
button is pressed.-->
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BorderBrush"
Storyboard.TargetProperty="Color"
To="Transparent"/>
</Storyboard>
</VisualState>
<!--The Disabled state is omitted for brevity.-->
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
注釈
は VisualState 、コントロールが特定の状態にある場合のコントロールの外観を指定します。 たとえば、 が押されると Button 、境界線の色が通常とは異なる場合があります。 VisualStateクラスには、コントロールのStoryboard外観を変更する プロパティがあります。 コントロールが プロパティで VisualState.Name 指定された状態になると、 が Storyboard 開始されます。 コントロールが状態を終了すると、 は Storyboard 停止します。
プロパティには VisualStateGroup.States オブジェクトが VisualState 含まれています。 VisualStateGroup オブジェクトは、 の VisualStateManager.VisualStateGroups で定義されている添付プロパティに FrameworkElement追加されます。 オブジェクトは任意FrameworkElementの に追加VisualStateできますが、通常、 の でControlTemplateControl使用されます。 既存のコントロールの オブジェクトと オブジェクトを作成する方法については、「ControlTemplate を作成して既存のコントロールの外観をカスタマイズする」を参照してください。ControlTemplateVisualState の外部ControlTemplateでオブジェクトを使用VisualStateする例については、 クラスをVisualStateManager参照してください。
コンストラクター
VisualState() |
VisualState クラスの新しいインスタンスを初期化します。 |
プロパティ
DependencyObjectType |
このインスタンスの DependencyObjectType CLR 型をラップする を取得します。 (継承元 DependencyObject) |
Dispatcher |
この Dispatcher が関連付けられている DispatcherObject を取得します。 (継承元 DispatcherObject) |
IsSealed |
このインスタンスが現在シールされている (読み取り専用である) かどうかを示す値を取得します。 (継承元 DependencyObject) |
Name |
VisualState の名前を取得または設定します。 |
Storyboard |
コントロールが Storyboard で表される状態のときに、コントロールの外観を定義する VisualState を取得または設定します。 |
メソッド
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示