【问题标题】:WPF hyperlink in RichTextBox click eventRichTextBox 单击事件中的 WPF 超链接
【发布时间】:2017-07-01 02:05:38
【问题描述】:

我想向 RichTextBox 添加一个超链接,然后在单击该链接时导航到另一个窗口。

这就是我所拥有的:

 // 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)
 {
     ...
 }

当我运行应用程序时,会显示超链接,但是当我单击它时没有任何反应。永远无法达到link_click 方法。

【问题讨论】:

    标签: c# wpf hyperlink richtextbox


    【解决方案1】:

    设置

     richTextBox.IsDocumentEnabled = true 
    

    按住 Ctrl 键并单击超链接。它应该可以工作。

    如果您不喜欢按住 Ctrl 键,请参阅 this post

    【讨论】:

      猜你喜欢
      • 2013-05-06
      • 2020-07-20
      • 1970-01-01
      • 1970-01-01
      • 2010-10-20
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      • 2011-08-08
      相关资源
      最近更新 更多