Gets the collection of mutually exclusive VisualState objects.
Namespace: System.Windows
Assembly: System.Windows (in System.Windows.dll)
Public ReadOnly Property States As IList
public IList States { get; }
<VisualStateGroup> oneOrMoreVisualStates </VisualStateGroup>
XAML Values
States is the XAML content property of VisualStateGroup and can thus support this content element syntax, as opposed to having to specify object.States as a property element.
Property Value
Type: System.Collections.IListThe collection of mutually exclusive VisualState objects.
The following example creates a simple ControlTemplate for a Button that contains one Grid. It also contains a VisualStateGroup called CommonStates, which defines the MouseOver and Normal states. The VisualStateGroup also has a VisualTransition that specifies that it takes one half second for the Grid to change from green to red when the user puts the mouse over the Button.
<ControlTemplate TargetType="Button"> <Grid > <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualStateGroup.Transitions> <!--Take one half second to trasition to the MouseOver state.--> <VisualTransition To="MouseOver" GeneratedDuration="0:0:0.5"/> </VisualStateGroup.Transitions> <VisualState x:Name="Normal" /> <!--Change the SolidColorBrush, ButtonBrush, to red when the mouse is over the button.--> <VisualState x:Name="MouseOver"> <Storyboard> <ColorAnimation Storyboard.TargetName="ButtonBrush" Storyboard.TargetProperty="Color" To="Red" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid.Background> <SolidColorBrush x:Name="ButtonBrush" Color="Green"/> </Grid.Background> </Grid> </ControlTemplate>
Silverlight
Supported in: 5, 4, 3Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.