I'm using the RichTextBox.AppendText
function to add a string to my RichTextBox
. I'd like to set this with a particular colour. How can I do this?
Just try this:
TextRange tr = new TextRange(rtb.Document.ContentEnd, rtb.Document.ContentEnd);
tr.Text = "textToColorize";
tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);