VisualStateGroup.States Property (System.Windows)

Switch View :
ScriptFree
.NET Framework Class Library for Silverlight
VisualStateGroup.States Property

Gets the collection of mutually exclusive VisualState objects.

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

Visual Basic (Declaration)
Public ReadOnly Property States As IList
C#
public IList States { get; }
XAML Property Element Usage
<VisualStateGroup>
    oneOrMoreVisualStates
</VisualStateGroup>

XAML Values

oneOrMoreVisualStates

One or more object elements that is of type VisualState.

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.IList
The collection of mutually exclusive VisualState objects.
Examples

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.

Run this sample

XAML

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


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.

See Also

Reference

Other Resources