Recently I have decided to switch from the Forms RichTextBox to the WPF RichTextBox for my chat client. I've been reading up on applying properties to the text. I've found that I can use 2 methods to doing this.

Method 1:
Code:
TextRange tr = new TextRange(rtb.Document.ContentEnd, rtb.Document.ContentEnd);
tr.Text = "Some Text Here";
tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black);
Method 2:
Code:
Run r = new Run("Some Text Here");
r.FontFamily = new System.Windows.Media.FontFamily("Tahoma");
r.FontSize = 12;
r.FontStyle = System.Windows.FontStyles.Normal;
r.FontWeight = System.Windows.FontWeights.Regular;
r.Foreground = System.Windows.Media.Brushes.SteelBlue;
para.Inlines.Add(r);
At the moment I am using method 2. The server my client works uses a style-like tags around text to specify the color, font, weight, ect. So for each group of text in a style tag I create and add a new run object to the paragraph. My problem comes when I need to loop through the run to set hyperlinks and insert emoticons. Since all the text is not in a single run object I find that if a user uses a gradient (text fader) the style tags may open or close inside of a hyperlink or the emoticons text.

Eg. [style co:#D6D6D6]www.some[/style]site.com

"www.some" would be a run object and "site.com" would be another.

What I need to do is to figure how to either apply multiple properties to different segments of a run object or find a way to join multiple run objects. Unless there is some other way I have overlooked. I am still very new to WPF.

Here is a post with the method I use to add emoticons that shows how I loop through the run object.

Help with embedding images into a RichTextbox