WPF Textblock, linebreak in Text attribute

textblock, wpf

Solution

I know this is ressurecting an old question, but I had the same problem. The solution for me was to use HTML encoded line feeds (`
`).

Line1
Line2

Looks like

Line1 Line2

For more of the HTML encoded characters check out w3schools

Problem

Is there a way to have `\n` make a line break in a `TextBlock`? ``` <TextBlock Text="line1\nLine2" /> ``` Or is there a better way to force a middle line break, inside the `Text` attribute? ``` <LineBreak /> ``` This doesn't work for me, it needs to be the value of the `Text` attribute, because the text string is being set from an outside source. I'm familiar with `LineBreak` but it's not the answer I'm looking for.

Original source

Related problems