VisualStateManager.GoToState(FrameworkElement, String, Boolean) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Esegue la transizione del controllo tra due stati. Utilizzare questo metodo per eseguire la transizione degli stati nel controllo con un oggetto 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
Parametri
- control
- FrameworkElement
Controllo da eseguire per la transizione tra stati.
- stateName
- String
Stato a cui eseguire la transizione.
- useTransitions
- Boolean
true per utilizzare un VisualTransition oggetto per eseguire la transizione tra stati; in caso contrario, false.
Valori restituiti
true se il controllo è passato correttamente al nuovo stato; in caso contrario, false.
Eccezioni
Esempio
Nell'esempio seguente viene illustrato un controllo che usa il metodo per eseguire la GoToState transizione tra stati. Per l'intero esempio, vedere Creazione di un controllo con aspetto personalizzabile.
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
Commenti
Chiamare il GoToState metodo se si modificano gli stati in un controllo che usa in VisualStateManager .ControlTemplate Chiamare il GoToElementState metodo per modificare gli stati di un elemento all'esterno di un ControlTemplate oggetto , ad esempio se si usa un VisualStateManager oggetto in un UserControl oggetto o in un singolo elemento.