title: AvalonEdit WPF TextEditor (SharpDevelop): How to highlight a specific range of text?
body: <p>The incredibly awesome AvalonEdit WPF TextEditor control seems to lack an important feature, or at least i can't figure it out. <strong>Given an offset and a length, highlight that portion in the TextDocument with a HighlightColor</strong>. Simple, right?</p>
  
  <p>Apprentely not. I've RTFM, and the documentation on "Syntax Highlighting" confused me even more. <a href="http://community.sharpdevelop.net/forums/p/10592/29190.aspx#29190" rel="noreferrer">Someone else asked the same question in the SharpDevelop forums</a>, and i'm afraid i can't make sense of Herr Grunwald's answer.</p>
  
  <p>Here's my attempt, using the DocumentHighlighter class (of course it doesn't work):</p>
  
  <pre><code>    textEditor1.Text = "1234567890";
  
      HighlightingColor c = new HighlightingColor() { FontWeight = FontWeights.ExtraBold };
  
      DocumentHighlighter dh = new DocumentHighlighter(textEditor1.Document, new HighlightingRuleSet());
      HighlightedLine hl = dh.HighlightLine(1);
  
      hl.Sections.Add(new HighlightedSection() { Color = c, Offset = 1, Length = 3 });
  </code></pre>
  
  <p>Thank you for helping!</p>