Is there a way to find the new focused control in the PreviewLostKeyboardFocus handler? For example, I have a textbox control with the PreviewLostKeyboardFocus event and I clicked on another control. Is there a way to find out what the new control is within the PreviewLostKeyboardFocus handler method?
The strange part is that textbox.IsFocused returns false, and FocusManager.GetFocusedElement(Application.Current.MainWindow) returns the current textbox control.
Many thanks in advence!
You should set the
TabIndexproperty of your controls.Supposedly, the next control to get the focus will be the one with the next TabIndex.
Regarding your next question, IsFocused is set at runtime. So, if you look at the TextBox properties with a debugger, you should see IsFocused
trueonly when the keyboard is at it.