Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin forms Label new line

I have a Label in my Xamarin forms page, that receives it's Text from it's view model, and the text contains the \n character. How can I make the Label to automatically split the text into two different rows?

like image 850
IdoT Avatar asked Mar 08 '15 13:03

IdoT


People also ask

What is StackLayout in Xamarin forms?

StackLayout organizes views in a one-dimensional line ("stack"), either horizontally or vertically. Views in a StackLayout can be sized based on the space in the layout, using layout options.

What is Flex layout in Xamarin forms?

The Xamarin. Forms FlexLayout is new in Xamarin. Forms version 3.0. It is based on the CSS Flexible Box Layout Module, commonly known as flex layout or flex-box, so called because it includes many flexible options to arrange children within the layout. FlexLayout is similar to the Xamarin.


2 Answers

Very simple add following unicode instead of \n

 


for ex:

Text="General 
 Studies - I"
like image 175
Ranjithkumar Avatar answered Sep 22 '22 13:09

Ranjithkumar


One way to solve it would be replacing in your VM the '\n' with System.Environment.NewLine

string Text = "Text first line\nText second line".Replace("\n", System.Environment.NewLine);

https://stackoverflow.com/a/56981145/4230687

like image 45
Motumbo Avatar answered Sep 21 '22 13:09

Motumbo