How do I programmatically change focus?
You can programmatically change focus to another user interface element using the MoveFocus() method.
First, you need to determine which UI element has focus. For example:
IInputElement focusedElement = FocusManager.GetFocusedElement(thisWindow);
Next, you cast the element to UIElement and call its MoveFocus() method:
UIElement uiElement = focusedElement as UIElement;
uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
The FocusNavigationDirection enumeration includes options such as Down, First, Last, Left, Next, Previous, Right, and Up
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 08/16/11
Comment or report problem with topic
