VisualTransition.From Property

July 28, 2014

Gets or sets the name of the VisualState to transition from.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public string From { get; set; }
<object From="stateName"/>

XAML Values

stateName

The name of the VisualState to transition from.

Property Value

Type: System.String
The name of the VisualState to transition from.

The From property is optional. A VisualTransition can be restricted to apply to only certain states or it can be applied any time the control transitions between states. You restrict when a VisualTransition is applied by setting the To and From properties. The following table describes the levels of restriction from most restrictive to least restrictive.

Type of restriction

Value of From

Value of To

From a specified state to another specified state

The name of a VisualState

The name of a VisualState

From any state to a specified state

Not set

The name of a VisualState

From a specified state to any state

The name of a VisualState

Not set

From any state to any other state

Not set

Not set

You can have multiple VisualTransition objects in a VisualStateGroup that refer to the same state, but they will be used in the order that the table above specifies.

You can change this behavior by creating a new class that inherits from VisualStateManager and overriding the GoToStateCore method.

The following example creates two VisualTransition objects. When the control transitions from the Pressed state to the MouseOver state, the VisualTransition that has both From and To set is used. When the control transitions from a state that is not Pressed to the MouseOver state, the other state is used.


<!--Take one half second to trasition to the MouseOver state.-->
<VisualTransition To="MouseOver" 
                      GeneratedDuration="0:0:0.5" />

<!--Take one hundredth of a second to transition from the
    Pressed state to the MouseOver state.-->
<VisualTransition From="Pressed" To="MouseOver" 
                      GeneratedDuration="0:0:0.01" />


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft