RichTextBox 点击事件中的 WPF 超链接
WPF hyperlink in RichTextBox click event
我想将 hyperlink 添加到 RichTextBox,然后在单击 link 时导航到另一个 window。
这是我的:
// 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)
{
...
}
当我运行应用程序时,显示了hyperlink,但是当我点击它时没有任何反应。从未达到 link_click
方法。
设置
richTextBox.IsDocumentEnabled = true
按住 Ctrl 键并单击超链接。它应该可以工作。
如果您不喜欢按住 Ctrl,请参阅 this post。
我想将 hyperlink 添加到 RichTextBox,然后在单击 link 时导航到另一个 window。
这是我的:
// 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)
{
...
}
当我运行应用程序时,显示了hyperlink,但是当我点击它时没有任何反应。从未达到 link_click
方法。
设置
richTextBox.IsDocumentEnabled = true
按住 Ctrl 键并单击超链接。它应该可以工作。
如果您不喜欢按住 Ctrl,请参阅 this post。