How can I insert text into a WPF textbox at caret position? What am I missing? In Win32 you could use CEdit::ReplaceSel().
It should work as if the Paste() command was invoked. But I want to avoid using the clipboard.
How can I insert text into a WPF textbox at caret position? What am I missing? In Win32 you could use CEdit::ReplaceSel().
It should work as if the Paste() command was invoked. But I want to avoid using the clipboard.
Use TextBox.CaretIndex to modify the text bound to the TextBox.Text property.
If you want to move the caret after the inserted text the following code is useful
To simply insert text at the caret position:
To replace the selected text with new text:
To scroll the textbox to the caret position:
I found an even more simple solution by myself:
Then scroll to the position as stated by Tarsier.