How do you force a line break between two words in a XAML-declared Label?

wpf, xaml

Solution

If you only need to display text, you can use a `TextBlock` instead of a `Label`:

<TextBlock>
  Line<LineBreak/>Break:
</TextBlock>

If you really need a `Label` (e.g. you need to respond to a click event), you can wrap the above code inside a `Label`.

Problem

Maybe I'm not using the right key words, but all my searches are coming up empty. How do you force a line break? I can tell you that none of the following work: ``` <Label Content="Line&br;Break:" /> <Label Content="Line<br />Break:" /> <Label Content="Line Break:" /> <Label Content="Line\nBreak:" /> ``` Can someone share this closely guarded secret? Thanks. EDIT: Okay, never mind. I finally found it. ``` <Label Content="Line&#x0a;Break:" /> ``` Definitely not easy to guess! EDIT 2: Okay, and now to get the text to be right-justified, I went with this: ``` <Label> <TextBlock TextAlignment="Right" Text="Line&#x0a;Break:" /> </Label> ``` Thanks to Julien for the idea of using a TextBlock.

Original source

Related problems