TheDeveloper
TheDeveloper

Reputation: 1217

Xamarin Forms: Line break unicode works on xaml but on in code behind

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

Upvotes: 1

Views: 1092

Answers (1)

Morse
Morse

Reputation: 9144

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

Upvotes: 2

Related Questions