Tech Off Thread

3 posts

WPF: Find elements of specific type in FlowDocument

Back to Forum: Tech Off
  • User profile image
    Bas

    I'm trying to gather all hyperlinks from a RichTextBox in WPF, but the whole FlowDocument class is an enigma. I can find ways to find elements by name and resources by key, but I can't find any way to simply return a collection of all HyperLink comments in the document, or even in each of the document's Blocks. Is there a way to do this?

  • User profile image
    spivonious

    If the current Block is a Paragraph, you could check it's Inlines property for any Hyperlink objects.

     

    I don't think FlowDocument is designed to be that interactive.

  • User profile image
    footballism

    spivonious said:

    If the current Block is a Paragraph, you could check it's Inlines property for any Hyperlink objects.

     

    I don't think FlowDocument is designed to be that interactive.

    If I remember correctly, HyperLinks will be part of the logical tree of FlowDocument, so a simple pre-order traversal over the logical tree starting from the FlowDocument down to the reaf element should do the trick.

     

    Yong

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.