简体   繁体   中英

Detecting hyperlinks in WPF RichTextBox

Hey folks, I'm wanting to write some rudimentary support for detecting hyperlinks in a WPF RichTextBox control. My plan is to use a regex to identify any links and then manually replace them with real hyperlink objects.

However the part I am having trouble with is getting the correct textpointers, etc. once I find a link. For example, I can flatten the entire document to a text string and find links, but once I do that how can I get the proper pointer to the block that needs url-ifying?

Perhaps a better approach would be to iterate over blocks in the document, assuming a url would not span multiple blocks, however even then I have very little experience working with the RichTextBox/FlowDocument object model so any pointers (pun intended) would be helpful. Thanks!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM