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...
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.
Use TextBox.SelectedText, which has both a setter and a getter.
If no text is selected, SelectedText
is the zero-length range at the caret position.