TemplateVisualStateAttribute.Name 屬性

定義

取得或設定控制項可以處於的狀態名稱。

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

屬性值

String

控制項可以處於的狀態名稱。

範例

下列範例顯示 控制項的 NumericUpDown 類別簽章。 這個範例會 NumericUpDown 指定控制項使用四個視覺狀態。 名為 和 Negative 的兩個狀態 Positive 位於 VisualStateGroup 具名 ValueStates 的 中。 其他兩個狀態 name FocusedUnfocused 位於名為 FocusedStatesVisualStateGroup 中。 如需整個範例,請參閱 建立具有可自訂外觀的控制項

[TemplatePart(Name = "UpButtonElement", Type = typeof(RepeatButton))]
[TemplatePart(Name = "DownButtonElement", Type = typeof(RepeatButton))]
[TemplateVisualState(Name = "Positive", GroupName = "ValueStates")]
[TemplateVisualState(Name = "Negative", GroupName = "ValueStates")]
[TemplateVisualState(Name = "Focused", GroupName = "FocusedStates")]
[TemplateVisualState(Name = "Unfocused", GroupName = "FocusedStates")]
public class NumericUpDown : Control
<TemplatePart(Name:="UpButtonElement", Type:=GetType(RepeatButton))> _
<TemplatePart(Name:="DownButtonElement", Type:=GetType(RepeatButton))> _
<TemplateVisualState(Name:="Positive", GroupName:="ValueStates")> _
<TemplateVisualState(Name:="Negative", GroupName:="ValueStates")> _
<TemplateVisualState(Name:="Focused", GroupName:="FocusedStates")> _
<TemplateVisualState(Name:="Unfocused", GroupName:="FocusedStates")> _
Public Class NumericUpDown
    Inherits Control

備註

屬性 TemplateVisualStateAttribute.Name 會對應至 VisualState.NameVisualState 屬性。 若要指定 VisualState 屬於控制項的內容 ControlTemplate ,請設定 TemplateVisualStateAttribute.Name 屬性。

適用於