Search code examples
wpfxamlhyperlinkword-wrap

Text wrapping in WPF hyperlink


In my WPF application I have this:

<StackPanel>
  <TextBlock>
     <Hyperlink>
       <TextBlock TextWrapping="Wrap" Name="HyperlinkText" />
     </Hyperlink>
  </TextBlock>
</StackPanel>

But if I set HyperlinkText.Text to a long text that wraps, the whole text is underlined only once at the bottom (see image). Is there a way to have every line underlined separately without manual wrapping?


Solution

  • An easier way to achieve that is to use Run instead of TextBlock.

    Hope it helps.