How to add a line break in a label. I have a label in which i m adding a text which will result in this display
A
B
C
i have done this in WinForms c# with Environment.NewLine
but this is not working in WPF application
Can some one tell me how can i add line break in label?
Am doing this from code behind and not XAML
If you're fine with using TextBlock instead of Label (you should be!), then you can do it like this:
<TextBlock>
<Run Text="First Line"/>
<LineBreak/>
<Run Text="Second Line"/>
</TextBlock>
You can do this from code behind as well (not sure why you would want to though):
tb.Inlines.Add(new Run("First Line"));
tb.Inlines.Add(new LineBreak());
tb.Inlines.Add(new Run("Second Line"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With