WPF Textblock, linebreak in Text attribute

Try this:

<TextBlock>
    line1
    <LineBreak />
    line2
</TextBlock>

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 (&amp;#10;).

Line1&amp;#10;Line2

Looks like

Line1
Line2

For more of the HTML encoded characters check out w3schools


The easiest way is

<TextBlock> blabla <LineBreak /> coucou <LineBreak /> coucou 2 </TextBlock>

So you just write XAML code, and the <LineBreak /> has exactly the same meaning the
in HTML or the "\n" in C#.

Tags:

Wpf

Textblock