Name Property
Collapse the table of content
Expand the table of content

VisualState.Name Property


Gets or sets the name of the VisualState.

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

public string Name { get; set; }

Property Value

Type: System.String

The name of the VisualState.

You specify which visual state an element should enter by passing the Name of the VisualState to the VisualStateManager.

When a Control uses the VisualStateManager in a ControlTemplate, the control author should 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.

To find the names of the visual states for the controls that are included with WPF, see Control Styles and Templates. For information about how to create a ControlTemplate and VisualState objects for existing controls, see Customizing the Appearance of an Existing Control by Creating a ControlTemplate.

Legacy Code Example

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 Creating a ControlTemplate.

Code snippet is not found. Confirm that the code snippet name 'VSMButtonTemplate' is correct.

.NET Framework
Available since 4.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft