Windows Presentation Foundation User's Guide > Howto: Edit and Format Text From Code
As an alternative to specifying start position and length of a word to be selected, the TextControl.Find method can be used to locate it. In this example, the font size of the word 'Text' is changed.
[C#] textControl1.Text = "TX Text Control"; textControl1.Find("Text"); textControl1.Selection.FontSize = 400;
[Visual Basic] TextControl1.Text = "TX Text Control" TextControl1.Find("Text") TextControl1.Selection.FontSize = 400
It is also possible to replace a piece of text once it has been selected. Note that there is no dedicated Replace method for this purpose, you simply use the Selection.Text property instead.