Here is what I would like to do:
<Label Text="Choose By\nOne\nTwo" Margin="0,10,0,0" />
However the only thing this does is make the characters \n appear twice in the label. Is there any way that I can add a line feed in as part of a label's text?
You should use
<Label Text="Choose By One Two" Margin="0,10,0,0" />
and the result will look like \n

I just ran into this, but for me I was sending a string from a server to the device and needed a way to keep line feeds in the text. I ended up having to process the text on the device and find my special <THIS IS A LINE FEED> character and replace it with Environment.NewLine.
So something like this:
In your XAML:
<Label Text="{Binding Something}" Margin="0,10,0,0" />
OR
<Label x:Name="LabelMy" Margin="0,10,0,0" />
Then in code behind or ViewModel:
string normalText = "Choose By\nOne\nTwo";
string fixedText = normalText.Replace("\n", Environment.NewLine);
ViewModel.Something = fixedText;
//OR
LabelMy.Text = fixedText;
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