콘텐츠로 이동

FocusManager.SetFocus method (1 of 2)

이 콘텐츠는 아직 번역되지 않았습니다.

Sets focus to the specified element after resolving its default focus target; returns false when the element cannot take focus.

public bool SetFocus(UIElement? element)

Sets focus to the specified element; returns false when the element cannot take focus.

public bool SetFocus(UIElement? element, bool resolveDefault)
parameter description
element The element to focus.
resolveDefault When true, applies GetDefaultFocusTarget redirection (e.g. a container forwards focus to its first focusable child). Programmatic and keyboard-driven focus should use this path. Mouse-click-driven focus should pass false - the click already expresses a precise location, so silently redirecting focus elsewhere (possibly off-screen) violates user intent and can trigger unwanted scroll-into-view.