I'm using a RichTextBox in WPF and want to:
- Input text
- Save text to an object
- Save the selection
- Clear RTB
- Insert the text from the object
- Set the previous selection again
1 and 2 is done, easy. I can easily save the selection using the Selection property on the RTB to get the TextSelection object. But after clearing the RTB the, the TextSelection object changes so i cannot use it to restore the selection.
So how can i achive this?