title: Underline selection only in RichTextBox
body: <p>I am implementing basic formatting functionality (bold, italic, underline) to a RichTextBox in WPF by means of buttons that trigger such functionality (see my <a href="https://stackoverflow.com/questions/25114109/detect-when-caret-position-changes-in-richtextbox">previous question</a> if you need some context).</p>
  
  <p>As in <a href="https://stackoverflow.com/a/7014700/983064">this answer</a>, I can apply underlining by something like the following:</p>
  
  <pre><code>selectionRange.ApplyPropertyValue(Inline.TextDecorationsProperty, TextDecorations.Underline);
  </code></pre>
  
  <p>The problem is that this seems to apply the underline to the entire <code>Inline</code>. For example, if I have the text "<code>Chuck Norris</code>", and I only highlight "<code>Norris</code>", then the whole of "<code>Chuck Norris</code>" gets highlighted when I click the underline button.</p>
  
  <p>This problem does not apply to bold and italic since I am using <code>TextElement.FontWeightProperty</code> and <code>TextElement.FontStyleProperty</code>, but when using <code>Inline.TextDecorationsProperty</code> I get the problem I just described.</p>
  
  <p>Is there any way to make the underline apply only to the selected text, and not to the entire <code>Inline</code>?</p>