title: WPF RichTextBox change font color inline
body: <p>I've searched for a while for this solution, so now I'm posting here.</p>
  
  <p>Right now I am able to change the foreground color of the whole <code>RichTextBox</code>:</p>
  
  <pre><code>yourRichTextBox.Foreground = Brushes.Red;
  </code></pre>
  
  <p>I'm also able to change the color of some text that a user has selected with their cursor:</p>
  
  <pre><code>if(!yourRichTextBox.Selection.IsEmpty){
      yourRichTextBox.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);
  }
  </code></pre>
  
  <p>But I want to be able to change the color of the next text that the user types.  </p>
  
  <p>I have a color picker box that returns the color a user wants the text to be in.  So the user is typing in the <code>RichTextBox</code> in normal black font, then they would click the color picker button, select a color, hit OK and then the next thing they type will be in that color.  Is there a way to do this or am I out of luck?</p>
  
  <p>The only way I can think to do it is to have a buffer that captures each character the user types, and then set the foreground property on each letter typed and then add it back into <code>RichTextBox</code>, ideas? </p>