Take the 2-minute tour ×

I have a richtextbox that works. But I want to make a button in the toolbar(where you can edit the richtextbox) to insert a piece of text ( the text will be: " {...} ").

What did i do already:

I made a button in the toolbar. Now is my question: how do you insert this string on the place where the cursor stands?


share|improve this question
By RichTextEditor, do you mean: <textcontrol.com/en_US/sites/rich-text-editor/>;? It pays to be explicit with ALL non-standard controls. Which version? Also, sadly, you're not likely to get much help with such a "specialised question" on a general programming forum. Mailing lists for the specific product are generally more fruitful. It'd be nice IF SOF was the perferred Q&A platform for ALL programming fields; but it isn't (yet). –  corlettk May 2 '11 at 11:08
add comment

1 Answer

up vote 0 down vote accepted

Replace the selected text using the SelectedText. That does mean that when there is a selection it is overriden, but I'm sure if you want to simply insert you can move the caret first.

Edit: I assumed you meant RichTextBox here. Sorry if that's not what you meant.

share|improve this answer
yeah I meant the richtextbox in xaml.. But how do you know where the cursor stands? –  Stef May 2 '11 at 11:16
@Stef, You use the SelectionStart property. At first glance (without testing) you can remove the selection by using the SelectionLength property. –  Matt May 2 '11 at 11:26
add comment

Your Answer


