0

I have added Label inside StackLayout. I have set HeightRequest for StackLayout and long text for Label.

I want to crop the exceed text in label. But it gets rendered outside of StackLayout. How to restrict that.

I don't want to set HeightRequest for Label.

<StackLayout Margin="10" HeightRequest="42" BackgroundColor="Yellow">
               <Label  VerticalOptions="Center" Text="A minimum 5 characters password contains a combination of uppercase and lowercase letter and number are required. A minimum 5 characters password contains a combination of uppercase and lowercase letter and number are required."/>

           </StackLayout>
Muneesh Kumar
  • 196
  • 1
  • 1
  • 10

2 Answers2

0

The size and position of child views within a StackLayout depends upon the values of the child views' HeightRequest and WidthRequest properties, and the values of their HorizontalOptions and VerticalOptions properties.

In a vertical StackLayout, child views expand to fill the available width when their size isn't explicitly set. Similarly, in a horizontal StackLayout, child views expand to fill the available height when their size isn't explicitly set.

For more details, you could refer to the MS docs. https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/stacklayout

Wendy Zang - MSFT
  • 10,509
  • 1
  • 7
  • 17
0

In order to set the Label Height based on the StackLayout in above code, please set the Orientation="Horizontal" for stackLayout.

Qwerty
  • 429
  • 2
  • 8