FrameworkElement.MoveFocus(TraversalRequest) 메서드

정의

키보드 포커스를 이 요소 반대쪽에 있는 다른 요소를 향해 제공된 이동 방향으로 이동합니다.Moves the keyboard focus away from this element and to another element in a provided traversal direction.

public:
 override bool MoveFocus(System::Windows::Input::TraversalRequest ^ request);
public override sealed bool MoveFocus (System.Windows.Input.TraversalRequest request);
override this.MoveFocus : System.Windows.Input.TraversalRequest -> bool
Public Overrides NotOverridable Function MoveFocus (request As TraversalRequest) As Boolean

매개 변수

request
TraversalRequest

포커스를 이동할 방향(열거형의 값)입니다.The direction that focus is to be moved, as a value of the enumeration.

반환

포커스가 이동되었으면 true를 반환하고, 지정된 방향에 대상 요소가 없거나 대상 요소에 키보드 포커스를 설정할 수 없으면 false를 반환합니다.Returns true if focus is moved successfully; false if the target element in direction as specified does not exist or could not be keyboard focused.

예제

다음 예제에서는 몇 가지 가능한 단추 입력을 처리 하는 처리기를 구현 합니다.The following example implements a handler that handles several possible button inputs. 각 단추는 가능한 FocusNavigationDirection를 나타냅니다.Each button represents a possible FocusNavigationDirection. 처리기는 현재 키보드 포커스가 있는 요소를 추적 하 고 제공 된 TraversalRequest 형식 매개 변수에 대 한 초기화로 적절 한 FocusNavigationDirection 지정 하 여 해당 요소에서 MoveFocus를 호출 합니다.The handler tracks the element with current keyboard focus, and calls MoveFocus on that element, by specifying the appropriate FocusNavigationDirection as initialization for the TraversalRequest type parameter provided.

// Creating a FocusNavigationDirection object and setting it to a
// local field that contains the direction selected.
FocusNavigationDirection focusDirection = _focusMoveValue;

// MoveFocus takes a TraveralReqest as its argument.
TraversalRequest request = new TraversalRequest(focusDirection);

// Gets the element with keyboard focus.
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;

// Change keyboard focus.
if (elementWithFocus != null)
{
    elementWithFocus.MoveFocus(request);
}
' Creating a FocusNavigationDirection object and setting it to a
' local field that contains the direction selected.
Dim focusDirection As FocusNavigationDirection = _focusMoveValue

' MoveFocus takes a TraveralReqest as its argument.
Dim request As New TraversalRequest(focusDirection)

' Gets the element with keyboard focus.
Dim elementWithFocus As UIElement = TryCast(Keyboard.FocusedElement, UIElement)

' Change keyboard focus.
If elementWithFocus IsNot Nothing Then
    elementWithFocus.MoveFocus(request)
End If

설명

이 구현은 UIElement.MoveFocus를 재정의 하 고 메서드를 봉인 합니다.This implementation overrides UIElement.MoveFocus and seals the method.

적용 대상

추가 정보