MAUI Label inside layouts are not aligning properly

Satya 85 Reputation points
2023-05-29T09:22:17.62+00:00

I have to show two labels side by side which are centered in a layout based on dynamic text. It was working fine in Xamarin forms, but not in MAUI.

Label is not centering and LineBreakMode is also not working.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="MAUIAPP.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

    <ScrollView>
        <StackLayout
            Margin="25"
            HorizontalOptions="Center"
            Orientation="Horizontal"
            Spacing="0">

            <!--  Worddwrap is not working and label is auto adjusting in maui  -->

            <Label
                FontSize="16"
                LineBreakMode="WordWrap"
                Text="Please reach out me on this mobile number :" />

            <Label
                FontSize="16"
                Text="1234567890"
                TextColor="Blue">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
                </Label.GestureRecognizers>
            </Label>


        </StackLayout>
    </ScrollView>

</ContentPage>



.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,897 questions
{count} votes