0
votes

I want to have line break in the xamarin label. But it only works in xaml but not in code behind. The text is not static so I cannot have it in XAML. Can anyone suggest how to have line break via code behind ?

Works:

<StackLayout x:Name="DetailsContainer" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="20" InputTransparent="True" WidthRequest="0">
    <Label x:Name=lbl Text="Line one &#10; Line two." StyleClass="h3"/>
</StackLayout>

If update the text like this in the xaml, the label would have a line break in the text but if I do the same in code behind it doesn't work

1
Is "Line one \n Line two." not working?Nongthonbam Tonthoi
No but Line one \r\n Line two is working.TheDeveloper

1 Answers

1
votes

in C# you should use \r\n(windows) \n(Unix type) or better Environment.NewLine