Reputation: 181
I need your help !
In xamarin.forms, I would like a Label with a fixed Width. When the text is too long, it is on several lines. So, I would like set a maximum height or number of lines. I think to measure the string lengh but I no found method.
I hope there is a solution to Xamarin.Forms (PCL project). I don't want to do specific code for each platform if it's possible.
Thank you in advance !
Upvotes: 3
Views: 9202
Reputation: 441
I found a solution.
When I set HeightRequest property to Label, it didn't work. When I wrapped the Label in a StackLayout and set HeightRequest property to the StackLayout, I succeeded.
<StackLayout Orientation="Horizontal" HeightRequest="70">
<Label Text="..." />
</StackLayout>
Upvotes: 5
Reputation: 993
There are a few options available. If you don't want the label to wrap you can set the Label.LineBreakMode
to NoWrap
. More info here.
You can directly specify a HeightRequest
or set VerticalOptions
on the Label.
Try posting a code example of what you have tried for more assistance.
Upvotes: 1