VisualState.Name プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
VisualStateの名前を取得または設定します。
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
プロパティ値
VisualStateの名前。
例
次の例では、CommonStates と呼ばれるButtonのControlTemplateにVisualStateGroupを作成し、状態、Normal、Pressed、およびMouseOverのVisualState オブジェクトを追加します。
Buttonでは、CommonStatesVisualStateGroup内にある Disabled と呼ばれる状態も定義されますが、簡潔にするために省略しています。 例全体については、「コントロールの テンプレートを作成する方法」を参照してください。
<!--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のNameをVisualStateManagerに渡すことで、要素が入力するビジュアル状態を指定します。
ControlがControlTemplateでVisualStateManagerを使用する場合、コントロールの作成者は、TemplateVisualStateAttributeをクラス シグネチャに配置することによって、コントロールがControlTemplateで見つけるオブジェクトVisualStateを指定する必要があります。 ControlTemplate 作成者は新しい VisualState オブジェクトを定義し、 Name プロパティを TemplateVisualStateAttribute.Name プロパティで指定された値に設定します。
WPF に含まれているコントロールの表示状態の名前については、「 コントロールのスタイルとテンプレート」を参照してください。 既存のコントロールの ControlTemplate オブジェクトと VisualState オブジェクトを作成する方法については、「 コントロールのテンプレートを作成する方法」を参照してください。