jwize1

What is the best way to combine two inlines or text blocks from a section of selected text.

samle text

Each word is an inline or a textbox in this sample text I want to convert these words to a single inline element.

As explained in the sample text there are inlines created for each word and space. How do I capture the selection delete it an add a new inline. I am sure this is a really simple but I am asking in advance just in case I can't find the answer quickly.

Thanks for any help, Jaime Weise



Re: Windows Presentation Foundation (WPF) RichTextBox combining Inlines.

LesterLobo - MSFT

you can get the selection through rtb.Selection

to delete the selection, set the selection.Text=""

Insert text through rtb.CaretPosition.InsertTextinRun ...the same can be done at any textpointer position.

Finally you can merge the selected words into a single inline by setting the same format property on them... TextRange.ApplyPropertyvalue





Re: Windows Presentation Foundation (WPF) RichTextBox combining Inlines.

jwize

Ok great, then how would I get the text range for the active selection. I am looking into TextRanges at the moment. Thanks for the help.

Jaime Weise





Re: Windows Presentation Foundation (WPF) RichTextBox combining Inlines.

LesterLobo - MSFT

RichTextBox rtb

rtb.Selcection gives the active selection (which is also the textrange - selection derives from textrange)