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

개체를 사용하여 상태 간을 전환하려면 A를 사용하고, 그렇지 않으면 .

반품

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

예외

controlnull입니다.

-또는-

stateNamenull입니다.

예제

다음 예제에서는 상태 간에 전환 하는 메서드를 사용 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 상태를 변경합니다(예: 단일 요소에서 또는 단일 요소에서 VisualStateManager 사용하는 UserControl 경우).

적용 대상