WPF Richtextbox 中的超链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16506833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hyperlink in WPF Richtextbox
提问by Al___
I load WPF Richtextbox contents from Xaml string in which there are some Hyperlinks. When it is loaded into control, Hyperlinks are not clickable! I want to click on them and their associated URL shows up.
我从 Xaml 字符串加载 WPF Richtextbox 内容,其中有一些超链接。当它加载到控件中时,超链接不可点击!我想点击它们,它们的关联 URL 就会显示出来。
采纳答案by freschx
Ensure the DetectUrlsproperty on the RichTextbox is set to true. You can then attach an event handler to the link clicked event and do what you wish.
确保DetectUrlsRichTextbox 上的属性设置为 true。然后,您可以将事件处理程序附加到链接单击事件并执行您希望的操作。
<RichTextBox DetectUrls="True" />
Potential duplicate thread. Credit goes to Sam Meldrumfrom this thread.
For an even deeper analysis you may wish to try this article.
对于更深入的分析,您不妨试试这篇文章。
回答by hillin
No freschx, it's about WPF. A WPF RichTextBox, unlike the one in WinForms, does not have a DetectUrlsproperty. And it's weird you wrote a Xaml code for that, even weirder there is someone who thought it useful.
没有freschx,它是关于WPF 的。与 WinForms 中的WPFRichTextBox不同,WPF没有DetectUrls属性。奇怪的是你为此编写了 Xaml 代码,更奇怪的是有人认为它很有用。
Check this postout where JHubbard80and me had two different approaches to solve this problem.
查看这篇文章,看看JHubbard80和我有两种不同的方法来解决这个问题。

