July 28, 2014
Transitions the control between two states.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Shared Function GoToState ( _ control As Control, _ stateName As String, _ useTransitions As Boolean _ ) As Boolean
- Type: System.Windows.Controls.Control
The control to transition between states.
- Type: System.String
The state to transition to.
Return ValueType: System.Boolean
true if the control successfully transitioned to the new state; otherwise, false.
The GoToStateCore method performs the logic necessary to appropriately start and stop the storyboards that are associated with a transition. When a control calls to change its state, the VisualStateManager does the following:
If the control is already in the stateName state, takes no action returns true.
If stateName doesn't exist in the ControlTemplate of control, takes no action and returns false.
The following example demonstrates a control using the GoToStateCore method to transition between states.
Private Sub UpdateStates(ByVal useTransitions As Boolean) If Value >= 0 Then VisualStateManager.GoToState(Me, "Positive", useTransitions) Else VisualStateManager.GoToState(Me, "Negative", useTransitions) End If If isFocused Then VisualStateManager.GoToState(Me, "Focused", useTransitions) Else VisualStateManager.GoToState(Me, "Unfocused", useTransitions) End If End Sub