none
Run Element Level control over text wrapping in text block to prevent splitting of a run RRS feed

  • Question

  • Hello everyone, I am using a TextBlock which has embedded hyperlink elements inside the text. When this is resized, in some cases, the hyperlink is split onto multiple lines, because the Wrapping system seems to treat forward slashes as wrap points. I would like to override the behavior and tell the TextBlock that is cannot delimit any part of the hyperlink, and must move the entire block to the next line. How can I accomplish this?

    ThreeSevenths

    • Edited by ThreeSevenths Tuesday, May 25, 2010 5:55 PM spelling error
    Monday, May 24, 2010 4:39 PM

Answers

  • Hi,

    In this case, we could modify Hyperlink with another TextBlock element without wrap, the code should be:


            <TextBlock TextWrapping="WrapWithOverflow" > Is happy to have<TextBlock TextWrapping="NoWrap" > <Hyperlink>http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8ceee7e9-e224-428a-aaec-b593a120f6b1</Hyperlink> on the case.
            </TextBlock>
    </TextBlock>

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Tim Li Monday, May 31, 2010 3:35 PM
    Monday, May 31, 2010 3:35 PM

All replies

  • Hi ThreeSevenths,

    Do you have a code snippet that demonstartaes how your hyper link is placed? I would help us to give you more specifc answer if you describe your scenario as detail as possible.

    Thanks.

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by frippy_cmos Thursday, October 4, 2012 2:05 PM
    • Unproposed as answer by frippy_cmos Thursday, October 4, 2012 2:06 PM
    Wednesday, May 26, 2010 9:03 AM
  • Hi Tim Li, I am placing them in a TextBlock element in a similar fashion to this:

    <TextBlock TextWrapping="WrapWithOverflow" TextOptions.TextFormattingMode="Display">
     Is happy to have <Hyperlink>http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8ceee7e9-e224-428a-aaec-b593a120f6b1</Hyperlink> on the case.
    </TextBlock>

    Thanks for your time.

    ThreeSevenths

    Thursday, May 27, 2010 11:25 AM
  • Hi,

    In this case, we could modify Hyperlink with another TextBlock element without wrap, the code should be:


            <TextBlock TextWrapping="WrapWithOverflow" > Is happy to have<TextBlock TextWrapping="NoWrap" > <Hyperlink>http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8ceee7e9-e224-428a-aaec-b593a120f6b1</Hyperlink> on the case.
            </TextBlock>
    </TextBlock>

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Tim Li Monday, May 31, 2010 3:35 PM
    Monday, May 31, 2010 3:35 PM
  • Thanks for the solution. Do you know what the performance implications of adding another TextBlock element? I will be putting 100+ of these elements in a ListBox.

    Thanks,
    ThreeSevenths

    Monday, May 31, 2010 4:09 PM