VisualState.Name Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera lub ustawia nazwę VisualStateelementu .
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
Wartość właściwości
Nazwa elementu VisualState.
Przykłady
Poniższy przykład tworzy obiekt VisualStateGroup w ButtonControlTemplate obiekcie o nazwie CommonStates i dodaje VisualState obiekty dla stanów , Normal, Pressedi MouseOver. Element Button definiuje również stan o nazwie Disabled , który znajduje się w CommonStatesVisualStateGroupobiekcie , ale w przykładzie pominięto go w celu zwięzłości. W całym przykładzie zobacz Jak utworzyć szablon dla kontrolki.
<!--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>
Uwagi
Należy określić stan wizualizacji, który element powinien wprowadzić, przekazując NameVisualState element do elementu VisualStateManager.
Jeśli element Control używa VisualStateManager elementu w elemecie ControlTemplate, autor kontrolki powinien określić, które obiekty, których VisualState kontrolka oczekuje odnaleźć, ControlTemplate umieszczając sygnaturę TemplateVisualStateAttribute klasy. ControlTemplate autorzy definiują nowe VisualState obiekty i ustawiają Name właściwość na wartość określoną przez TemplateVisualStateAttribute.Name właściwość.
Aby znaleźć nazwy stanów wizualizacji dla kontrolek dołączonych do platformy WPF, zobacz Style kontrolek i szablony. Aby uzyskać informacje o sposobie tworzenia obiektów i VisualState dla istniejących kontrolek, zobacz How to create a template for a control (Jak utworzyć szablon dla kontrolki).ControlTemplate