VisualState.Name Właściwość

Definicja

Pobiera lub ustawia nazwę elementu 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

Wartość właściwości

String

Nazwa elementu VisualState.

Przykłady

Poniższy przykład tworzy obiekt VisualStateGroup w ControlTemplate wywołaniu CommonStates Button i dodaje VisualState obiekty dla stanów, Normal, Pressedi MouseOver. Element Button definiuje również stan o nazwie Disabled , który znajduje się w obiekcie CommonStates VisualStateGroup, ale w tym przykładzie pominięto go w celu zwięzłości. W całym przykładzie zobacz Dostosowywanie wyglądu istniejącej kontrolki przez tworzenie kontrolkiTemplate.

  <!--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

Określasz stan wizualizacji, który element powinien wprowadzić, przekazując Name VisualState element do VisualStateManagerelementu .

Jeśli element używa elementu VisualStateManager w elemecie Control ControlTemplate, autor kontrolki powinien określić, które VisualState obiekty, których 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 i szablony kontrolek. Aby uzyskać informacje o sposobie tworzenia ControlTemplate obiektów i VisualState dla istniejących kontrolek, zobacz Dostosowywanie wyglądu istniejącej kontrolki przez tworzenie kontrolkiTemplate.

Dotyczy