I have a user control for a textbox. In the codebehind of the user control i have a function called "TextBoxText_PreviewMouseDown", which shows a onscreen keyboard:
private void TextBoxText_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
TextBox textbox = sender as TextBox;
US_Keyboard keyboardWindow = new US_Keyboard(textbox, Window.GetWindow(this));
if (keyboardWindow.ShowDialog() == true)
textbox.Text = keyboardWindow.InputSource.Text;
}
my problem is, that if the onscreenkeyboard is shown, it gets the focus and in order to this the cursor disapears in the textbox.
The onscreenkeyboard is self made wpf keyboard (US_Keyboard), with a xaml file for the keyboard ui and a codebehind file for the keyboard logic.
here is the constructor of the keyboard:
public US_Keyboard(TextBox owner, Window wndOwner)
{
InitializeComponent();
MainWindow = wndOwner;
this.Owner = wndOwner;
this.DataContext = this;
InputSource = owner;
SetKeyboardSize();
SetKeyboardPosition();
}