Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个问题看起来很奇怪,但根据我的所有经验,我已经习惯于通过鼠标单击将键盘焦点设置为可聚焦元素;Focusable = true但是,带有属性的 UserControlIsTabStop = true让我感到惊讶,因为它通过 Tab 获得键盘焦点,但对鼠标点击却一无所知。
Focusable = true
IsTabStop = true
处理 UserControl 上的单击事件并将此代码添加到事件处理程序:
private void UserControl_OnMouseUp(object sender, MouseButtonEventArgs e) { Keyboard.Focus(sender as UserControl); }