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?
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.
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.
Very simple add following unicode instead of \n
for ex:
Text="General Studies - I"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With