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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.