textlabelmauimultiline

.Net MAUI Label text is displaying outside of the screen instead of multiline text


I am porting a Xamarin app that contain labels inside of a StackLayout, unfortunatelly the text is incomplete and it looks like the missing text is outside the screen.

How can I display the text of the label in multiple lines?

<StackLayout Orientation="Vertical" HorizontalOptions="Start">
    <Label Text="Pain and Stress Relief"
       FontSize="16"
       TextColor="Black"
       FontAttributes="Bold"
       VerticalOptions="Start" 
       HorizontalOptions="Start" />
    <Label Text="Users seeking relief from physical pain, inflammation, anxiety, or stress."
       FontSize="16"
       TextColor="Black"
       VerticalOptions="Start" 
       HorizontalOptions="Start" />
</StackLayout>

Xamarin display enter image description here

.NET MAUI display enter image description here


Solution

  • The solution that I found was to use a Grid instead of using a StackLayout

    <Grid HorizontalOptions="FillAndExpand">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Label Grid.Row="0" Text="Pain and Stress Relief"
           x:Name="label_title_01"
           FontSize="16"
           TextColor="Black"
           FontAttributes="Bold"
           VerticalOptions="Start" 
           HorizontalOptions="Start" />
        <Label Grid.Row="1" Text="Users seeking relief from physical pain, inflammation, anxiety, or stress."
           x:Name="label01"
           FontSize="16"
           TextColor="Black"
           VerticalOptions="Start" 
           HorizontalOptions="Start" />
    </Grid>