我想知道是否无论如何要从当前控件更改焦点并将其移动到 WPF 中 TabIndex 分配的控件上的其他控件。
示例我有 TabIndex 1 到 5 的控件,有没有办法将焦点从 1 跳到 5 ?
<TextBox TabIndex="1" Focusable = "true" LostFocus="test_LostFocus"/>
<TextBox TabIndex="2" Focusable = "true"/>
...
<TextBox TabIndex="5" Focusable = "true" name="LastControl"/>
.
private void test_LostFocus(object sender, RoutedEventArgs e)
{
LastControl.Focus();
}
我试过 了Keyboard.Focus()
,FocusManager.SetFocusedElement()
但没有运气。
任何的想法?