VisualStateManager.GoToState(FrameworkElement, String, Boolean) VisualStateManager.GoToState(FrameworkElement, String, Boolean) VisualStateManager.GoToState(FrameworkElement, String, Boolean) VisualStateManager.GoToState(FrameworkElement, String, Boolean) Method

Definition

Realiza la transición del control entre dos estados. Transitions the control between two states. Use este método para pasar de un estado a otro los controles que tengan ControlTemplate. Use this method to transition states on control that has a ControlTemplate.

public:
 static bool GoToState(System::Windows::FrameworkElement ^ control, System::String ^ stateName, bool useTransitions);
public static bool GoToState (System.Windows.FrameworkElement control, string stateName, bool useTransitions);
static member GoToState : System.Windows.FrameworkElement * string * bool -> bool
Public Shared Function GoToState (control As FrameworkElement, stateName As String, useTransitions As Boolean) As Boolean

Parámetros

control
FrameworkElement FrameworkElement FrameworkElement FrameworkElement

Control del que se va a realizar la transición entre estados. The control to transition between states.

stateName
String String String String

El estado al que se realiza la transición. The state to transition to.

useTransitions
Boolean Boolean Boolean Boolean

Es true para usar un objeto VisualTransition en la transición entre estados; de lo contrario, es false. true to use a VisualTransition object to transition between states; otherwise, false.

Returns

true si el control ha realizado correctamente la transición al nuevo estado; de lo contrario, false. true if the control successfully transitioned to the new state; otherwise, false.

Exceptions

control es null. control is null. O bien -or- stateName es null. stateName is null.

Examples

En el ejemplo siguiente se muestra un control que utiliza el GoToState método para realizar la transición entre Estados.The following example demonstrates a control that uses the GoToState method to transition between states. Para el ejemplo completo, vea crear un Control que tiene una apariencia personalizable.For the entire example, see Creating a Control That Has a Customizable Appearance.

private void UpdateStates(bool useTransitions)
{
    if (Value >= 0)
    {
        VisualStateManager.GoToState(this, "Positive", useTransitions);
    }
    else
    {
        VisualStateManager.GoToState(this, "Negative", useTransitions);
    }

    if (IsFocused)
    {
        VisualStateManager.GoToState(this, "Focused", useTransitions);
    }
    else
    {
        VisualStateManager.GoToState(this, "Unfocused", useTransitions);
    }
}
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

Remarks

Llame a la GoToState método si va a cambiar estados en un control que usa el VisualStateManager en su ControlTemplate.Call the GoToState method if you are changing states in a control that uses the VisualStateManager in its ControlTemplate. Llame a la GoToElementState método cambiar estados en un elemento fuera de un ControlTemplate (por ejemplo, si usa un VisualStateManager en un UserControl o en un solo elemento).Call the GoToElementState method to change states on an element outside of a ControlTemplate (for example, if you use a VisualStateManager in a UserControl or in a single element).

Applies to