Reputation: 1217
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 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
Reputation: 9144
in C# you should use \r\n
(windows) \n
(Unix type) or better Environment.NewLine
Upvotes: 2