Share via


VisualState.Name Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the name of the VisualState.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public ReadOnly Property Name As String
public string Name { get; }
<VisualState x:Name="stateName"/>

XAML Values

  • stateName
    The name of the VisualState. Name is a read-only property, so specify the name of the VisualState by setting x:Name.

Property Value

Type: System.String
The name of the VisualState.

Remarks

Control authors specify which VisualState objects the control expects to find in its ControlTemplate by putting the TemplateVisualStateAttribute on its class signature. ControlTemplate authors define new VisualState objects and set the Name property to the value specified by the TemplateVisualStateAttribute.Name property. For information about how to create a ControlTemplate and VisualState objects for existing controls, see Customizing the Appearance of an Existing Control by Using a ControlTemplate.

Examples

The following example creates a VisualStateGroup in the ControlTemplate of a Button called CommonStates and adds VisualState objects for the states, Normal, Pressed, and MouseOver. The Button also defines a state called Disabled that is in the CommonStatesVisualStateGroup, but the example omits it for brevity. For the entire example, see Customizing the Appearance of an Existing Control by Using a ControlTemplate.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.