Reputation: 931
When binding a Label.Text have tried many ways: \n \r but none of them are being displayed as breakline I refuse to believe I will need to dynamically create a Custom control to generate spans on numbers of breakline symbol... is there any easier/simpler approach ?
What I've tried:


Text second line"
Text second line"The xaml:
<Label Text="{Binding BreaklineText}"/>
It should be displayed on my view as Text first line Text second line
Upvotes: 0
Views: 669
Reputation: 74
I built on @Motumbo and set System.Environment.NewLine to a variable like
var nl = System.Environment.NewLine;
then I could write variations on:
string text = "some text" + nl + "text on newline";
Also found that "\r\n" works on Droid and UWP. Did not have iOS to test. So:
string text = "some text\r\ntext on newline";
worked for me.
Upvotes: 0
Reputation: 931
It's not the optimal solution since I wanted to find a symbol that could be interpreted as BreakLine on XAML, but it will do the job.
string BreaklineText = "Text first line\nText second line".Replace("\n", System.Environment.NewLine);
Upvotes: 1
Reputation: 9115
using Ascii equivalent
in XAML should work, you have missed ;
<Label Text="Text first line Text second line"/>
Upvotes: 0