Sdílet prostřednictvím


VisualState.Name Property

Definition

Gets the name of the VisualState.

public:
 property Platform::String ^ Name { Platform::String ^ get(); };
winrt::hstring Name();
public string Name { get; }
var string = visualState.name;
Public ReadOnly Property Name As String
<VisualState x:Name="stateName"/>

Property Value

String

Platform::String

winrt::hstring

The name of the VisualState.

Remarks

Name is a read-only property that you can check with code at run-time to read the value of the x:Name attribute that was applied to a VisualState in a XAML control template. You can't literally set Name because it's read-only, and x:Name attribute can only be set in XAML. The value is available as soon as the XAML that contains the control template and the VisualState definition is loaded.

The need to check the Name of a VisualState at run-time is anticipated to be relatively uncommon, and would only be relevant to advanced scenarios. For the most part, the definition of a VisualState in XAML combined with using VisualStateManager and VisualStateGroup events in code provides you all that you need to define and invoke visual states for a custom or Windows Runtime-defined control.

Applies to

See also