I have a WPF RichTextBox which contain in its FlowDocument both text and images. I need to iterate through the text's words (those which builds the text which the user see on the screen) and change their content and formatting. For instance, change the word "room" to the word "home", applying to the last a red color.
I need to change words whether they are formatted or unformatted. For instance, if a word is in Italic, colored, or just regular black text, it makes no difference for me.
Each word will be replaced with one which have about identical length, so I don't want that this operation will effect the general page layout. All images and other objects should remain at their positions.
It is preferred that the process of this operation will not be visible to the user. Only its result should be visible (i.e, no visible selections of text).
If this operation can be done either directly on the FlowDocumet or with properties/methods of the RichTextBox, the simple one is preferred (but exmaples for both will be ideal).
VB code examples will be great, but C# is welcome as well.
Thanks a lot
This is a tough one, since WPF doesn't have standard text search built right in. However, this link may provide some answers.