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
- 継承
- 属性
例
次の例では、呼び出されたオブジェクトの中に ControlTemplate a VisualStateGroup をButton作成しVisualState、状態、、Normal
および Pressed``MouseOver
.CommonStates
またButton、その中にあるCommonStates
VisualStateGroupと呼ばれるDisabled
状態も定義しますが、簡潔にするために省略しています。 例全体については、「 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>
注釈
A VisualState は、コントロールが特定の状態にある場合の外観を指定します。 たとえば、a Button を押すと、境界線の色が通常とは異なる場合があります。 この VisualState クラスには、 Storyboard コントロールの外観を変更するプロパティがあります。 コントロールがプロパティで VisualState.Name 指定された状態になると、 Storyboard 開始されます。 コントロールが状態を終了すると、停止します Storyboard 。
プロパティには VisualStateGroup.States オブジェクトが VisualState 含まれています。 VisualStateGroup オブジェクトは添付プロパティに VisualStateManager.VisualStateGroups 追加されます。このプロパティは FrameworkElement、 オブジェクトは任意FrameworkElementのオブジェクトに追加VisualStateできますが、通常はオブジェクトのControl中ControlTemplateで使用されます。 既存のコントロールとオブジェクトを作成する方法については、「ControlTemplate を作成して既存のコントロールの外観をカスタマイズする」を参照してください。ControlTemplate VisualState 外部ControlTemplateのオブジェクトを使用VisualStateする例については、クラスをVisualStateManager参照してください。
コンストラクター
VisualState() |
VisualState クラスの新しいインスタンスを初期化します。 |
プロパティ
DependencyObjectType |
このインスタンスの DependencyObjectType CLR 型をラップする値を取得します。 (継承元 DependencyObject) |
Dispatcher |
この Dispatcher が関連付けられている DispatcherObject を取得します。 (継承元 DispatcherObject) |
IsSealed |
このインスタンスが現在シールされている (読み取り専用である) かどうかを示す値を取得します。 (継承元 DependencyObject) |
Name |
VisualState の名前を取得または設定します。 |
Storyboard |
コントロールが Storyboard で表される状態のときに、コントロールの外観を定義する VisualState を取得または設定します。 |