WPF TextBox stealing focus after neighboring CheckBox is clicked

I've had an annoying issue with focus for controls on a ToolBar in WPF. My toolbar has a CheckBox and a TextBox control next to eachother. If you click and edit the text in the text box, then click the check box, the text box steals the focus back after clicking the check box, and the check box state is not changed when the user clicks on it.

I have similar issues with text boxes all over my application, but I believe this is the simplest case to explain, and I hope that the problem will be a common issue across all my text boxes.

Does anyone know what might be going on here?


将处理程序连接到复选框的Click事件(或者甚至是PreviewMouseUp事件),并将事件的Handled属性设置为'true'。


Did you try that?:

private void MyCheckBox_Click(object sender, RoutedEventArgs e) { MyCheckBox.Focus(); }

链接地址: http://www.djcxy.com/p/39260.html

上一篇: CRichEditCtrl在获取焦点时选择所有文本

下一篇: 单击相邻CheckBox后的WPF TextBox偷取焦点