I am implementing some sort of NumericKeypad Control for my WPF application which clients can use to conviniently enter text with a Touchscreen.
The Control itself runs fine, I even managed to run the Control (which is a Window) in the foreground while the TextBox, which is the target of the input, retains the focus and selection.
Now, I want to add the user's input into the TextBox's Text property just like if he had entered them with a keyboard. That means that certain behaviors should be adhered to, for instance...
- When the cursor is inbetween the Text, the character should be placed to where the cursor currently resides.
- When something is selected, the selection should be replaced with the entered character.
Is there anything I can use to do that? The only function I found is TextBoxBase.AppendText, which does not consider the cursor position or selection, but simply appends the entered String to the end of the Text.