States Property
Collapse the table of content
Expand the table of content

VisualStateGroup.States Property


Gets the collection of mutually exclusive VisualState objects.

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

Public ReadOnly Property States As IList

Property Value

Type: System.Collections.IList

The 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 named 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 moves the mouse pointer over the Button.

<ControlTemplate TargetType="Button">
  <Grid >
      <VisualStateGroup x:Name="CommonStates">


          <!--Take one half second to trasition to the MouseOver state.-->
          <VisualTransition To="MouseOver" 

        <VisualState x:Name="Normal" />

        <!--Change the SolidColorBrush, ButtonBrush, to red when the
            mouse is over the button.-->
        <VisualState x:Name="MouseOver">
            <ColorAnimation Storyboard.TargetName="ButtonBrush" 
              Storyboard.TargetProperty="Color" To="Red" />
      <SolidColorBrush x:Name="ButtonBrush" Color="Green"/>

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