VisualStateManager.GoToState(FrameworkElement, String, Boolean) 메서드

정의

두 상태 간의 컨트롤을 전환합니다. 이 메서드를 사용하여 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

매개 변수

control
FrameworkElement

상태 간에 전환할 컨트롤입니다.

stateName
String

전환되는 상태입니다.

useTransitions
Boolean

VisualTransition 개체를 사용하여 상태를 전환하려면 true이고, 그렇지 않으면 false입니다.

반환

Boolean

컨트롤이 새 상태로 성공적으로 전환되면 true이고, 그렇지 않으면 false입니다.

예외

control이(가) null인 경우

또는 stateName이(가) null인 경우

예제

다음 예제에서는 상태 간에 전환 하는 메서드를 GoToState 사용 하는 컨트롤을 보여 줍니다. 전체 예제를 보려면 모양을 사용자 지정할 수는 컨트롤에 만드는합니다.

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

설명

해당 컨트롤에서 GoToState 상태를 변경하는 경우 메서드를 VisualStateManager 호출합니다 ControlTemplate. 메서드를 GoToElementState 호출하여 외부 요소의 ControlTemplate 상태를 변경합니다(예: 단일 요소에서 또는 단일 요소에서 UserControl 사용하는 VisualStateManager 경우).

적용 대상