1

I want to add a hyperlink to a RichTextBox, then navigate to another window when the link is clicked.

This is what I have:

 // Add paragraphs to the FlowDocument
 Hyperlink link = new Hyperlink();
 link.IsEnabled = true;
 Paragraph paragraph = new Paragraph();
 myFlowDoc.Blocks.Add(paragraph);
 link.Inlines.Add(reviewAuthor);
 link.Click += new RoutedEventHandler(this.link_Click);
 paragraph.Inlines.Add(link);
 richTextBox.Document = myFlowDoc;

 protected void link_Click(object sender, RoutedEventArgs e)
 {
     ...
 }

When I run the application, the hyperlink is displayed, but nothing happens when I click on it. The link_click method is never reached.

Eutherpy
  • 4,471
  • 7
  • 40
  • 64

1 Answers1

2

Set

 richTextBox.IsDocumentEnabled = true 

hold down Ctrl key and Click on the Hyperlink. It should work.

See this post if you don't like to hold the Ctrl down.

Community
  • 1
  • 1
rmojab63
  • 3,513
  • 1
  • 15
  • 28