只用 Keyboard.Focus 似乎不能让像是在TreeViewItem的Header之类的属性中的文本框获取焦点。
Dispatcher.BeginInvoke(DispatcherPriority.Input,
new Action(delegate() {
目标TextBox.Focus(); // Set Logical Focus
Keyboard.Focus(目标TextBox); // Set Keyboard Focus
}));
原文地址:https://www.cnblogs.com/diculess/p/8494823.html
时间: 2024-12-18 03:39:49