Newline in string attribute

xaml

Solution

<TextBlock Text="Stuff on line1&#x0a;Stuff on line 2"/>

You can use any hexadecimally encoded value to represent a literal. In this case, I used the line feed (char 10). If you want to do "classic" `vbCrLf`, then you can use `&#x0d;&#x0a;`

By the way, note the syntax: It's the ampersand, a pound, the letter x, then the hex value of the character you want, and then finally a semi-colon.

ALSO: For completeness, you can bind to a text that already has the line feeds embedded in it like a constant in your code behind, or a variable constructed at runtime.

Problem

How can I add a line break to text when it is being set as an attribute i.e.: ``` <TextBlock Text="Stuff on line1 \n Stuff on line2" /> ``` Breaking it out into the exploded format isn't an option for my particular situation. What I need is some way to emulate the following: ``` <TextBlock> <TextBlock.Text> Stuff on line1 <LineBreak/> Stuff on line2 </TextBlock.Text> <TextBlock/> ```

Original source