title: Custom hyperlinks using AvalonEdit
body: <p>I'm trying to create custom hyperlinks using AvalonEdit. I've created a generator (based on the sample) which recognizes a syntax  and I can set a Uri:</p>
  
  <pre><code>  public class LinkGenerator : VisualLineElementGenerator
    {
      readonly static Regex imageRegex = new Regex(@"&lt;mylink&gt;", RegexOptions.IgnoreCase);
  
      public LinkGenerator()
      {}
  
      Match FindMatch(int startOffset)
      {
          // fetch the end offset of the VisualLine being generated
          int endOffset = CurrentContext.VisualLine.LastDocumentLine.EndOffset;
          TextDocument document = CurrentContext.Document;
          string relevantText = document.GetText(startOffset, endOffset - startOffset);
          return imageRegex.Match(relevantText);
      }
  
      /// Gets the first offset &gt;= startOffset where the generator wants to construct
      /// an element.
      /// Return -1 to signal no interest.
      public override int GetFirstInterestedOffset(int startOffset)
      {
          Match m = FindMatch(startOffset);
          return m.Success ? (startOffset + m.Index) : -1;
      }
  
      /// Constructs an element at the specified offset.
      /// May return null if no element should be constructed.
      public override VisualLineElement ConstructElement(int offset)
      {
          Match m = FindMatch(offset);
          // check whether there's a match exactly at offset
          if (m.Success &amp;&amp; m.Index == 0)
          {
              var line = new VisualLineLinkText(CurrentContext.VisualLine, m.Length);
  
              line.NavigateUri = new Uri("http://google.com");
              return line;
          }
          return null;
      }
  }
  </code></pre>
  
  <p>However there are two issues I can't seem to figure out:</p>
  
  <ol>
  <li><p>What do I pass to VisualLineLinkText constructor to simplify the text to say "MyLink"?</p></li>
  <li><p>Where do I put an event handler that will receive RequestNavigateEventArgs so I can override the click behavior?</p></li>
  </ol>