WPF 中的文本控件(例如 RichTextControl)内的可点击链接?
我希望能够有一些可点击的文本,就像 WPF 中的网页一样。该控件应该具有非功能性文本(用于显示)以及其某些部分完全可单击。
就像维基百科那样说。
但这是一个独立的离线应用程序。
我尝试了各种方法,但我无法做到这一点,尤其是单击功能不像网页那样,即单击一下即可打开工具中包含的网址。
I want to be able to have some text clickable like in webpages in WPF. The control should have both non-functional text (for display) both also some of its parts as completely clickable.
Say like Wikipedia.
But this is an independent standalone offline app.
I tried various things but I couldn't do it, especially the clicking doesn't function like web pages, i.e. 1 click to open the url contained within the tools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不要求它是一个完整的 FlowDocument,那么您可以只使用普通的旧 WPF TextBlock,并将超链接放入其中。
如果需要滚动,只需在其周围放置一个 ScrollViewer 即可。
如果您需要分页、多列查看器,那么您需要使用完整的 FlowDocument,但如果您想要的只是带有超链接的文本,那么 TextBlock + Hyperlink 应该就是您所需要的。
If you don't have a requirement that it be a full-blown FlowDocument, then you can just use a plain old WPF TextBlock, and put Hyperlinks in it.
If you need scrolling, just put a ScrollViewer around it.
If you need the paginated, multi-column viewer, then you'll need to go with an all-out FlowDocument, but if all you want is text with hyperlinks, TextBlock + Hyperlink should be all you need.
您应该尝试手动设置流程文档并在流程文档中创建超链接...
以下是取自以下链接的一些文本:
http://social.msdn .microsoft.com/Forums/en-US/wpf/thread/99ae9d9c-1dd4-4acd-8d5d-6eb739adeb98
“
你好,
这是有可能的。
这是创建指向段落/部分/表格的超链接的小示例。
为了导航到网站,我们可以创建一个用于导航的框架控件。本例中元素的层次关系是这样的:
Frame-->FlowDocument-->Table-->Section-->Paragraph-->Hyperlink
在后面的代码中:
如果您还有关于这个,请随意询问。
谢谢。 ”
you should try setting the flow document manually and creating hyperlinks within the flow document...
Here is some text taken from the following link:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/99ae9d9c-1dd4-4acd-8d5d-6eb739adeb98
"
Hi,
It is possible.
Here is a small example of creating hyperlink to paragraph/section/table.
In order to navigate to website, we can create a Frame Control for navigation. The hierarchical relationship of elements in this example is like this :
Frame-->FlowDocument-->Table-->Section-->Paragraph-->Hyperlink
In the code behind:
If you have any additional question about this,please feel free to ask.
Thanks. "