Is it possible to click a button without losing the attention of the TextBox?

I am trying to develop a touch screen keyboard control in a C # WPF project that will display when the TextBox receives focus and is hidden when the TextBox loses focus. The projects I saw for touch keyboards achieved this by defining the keyboard as a new window, not a control.

For my application, I would really like the keyboard to be as a control in the main application window. Is there a way to keep the button pressed (on the control keyboard) without causing the TextBox to lose focus? Ideally, I would just like to place the character at the current carat position.

+6
c # wpf keyboard focus touchscreen
source share
2 answers

Set Focusable="False" to the button. You can still click the mouse, and it will still call your click event handler, but it will not receive focus or lose the focus of the TextBox.

+21
source share

An alternative is to use a PictureBox instead of an o Button, then you configured it. PictureBox does not lose focus when pressed.

+1
source share

All Articles