问题
This question can seem quite odd but from all my experience I've gotten used to setting keyboard focus to the focusable element just by clicking it with the mouse; however, UserControl with the properties Focusable = true
and IsTabStop = true
came as a surprise to me because it gets keyboard focus via Tab but stays ignorant to mouse clicks.
回答1:
Handle the click event on the UserControl and add this code to the eventhandler:
private void UserControl_OnMouseUp(object sender, MouseButtonEventArgs e)
{
Keyboard.Focus(sender as UserControl);
}
来源:https://stackoverflow.com/questions/15600017/do-mouse-clicks-bring-keyboard-focus-to-focusable-controls-by-default