Compartir a través de


VisualStateGroup.Transitions Property

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

Gets the collection of VisualTransition objects.

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

Syntax

'Declaration
Public ReadOnly Property Transitions As IList
public IList Transitions { get; }
<VisualStateGroup>
  <VisualStateGroup.Transitions>
    oneOrMoreVisualTransitions
  </VisualStateGroup.Transitions>
</VisualStateGroup>

XAML Values

  • oneOrMoreVisualTransitions
    One or more object elements that is of type VisualTransition.

Property Value

Type: System.Collections.IList
The collection of VisualTransition objects.

Remarks

The VisualTransition objects in Transitions are applied when the control transition between states that are defined in the VisualStateGroup.

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

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