Search code examples
c#xamlmaui

Why does Maui AbsoluteLayout not show content when inside a StackLayout


I am having trouble with a .NET Maui app where nothing shows on a page when I use an AbsoluteLayout. I just get a blank page.

The code is below.

Something to note is the topmost StackLayout comes from a master page so I can't remove it. However the problem presents with the code as shown below.

Thanks

   <StackLayout  HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >

        <AbsoluteLayout  HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <ScrollView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" AbsoluteLayout.LayoutBounds="0,0,AutoSize, AutoSize" AbsoluteLayout.LayoutFlags="All">
                <VerticalStackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="Welcome to .NET MAUI!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                    <Label  Text="More labels!" VerticalOptions="Start"  HorizontalOptions="Start" />
                </VerticalStackLayout>
            </ScrollView>
        </AbsoluteLayout>

    </StackLayout>


Solution

  • This has nothing to do with StackLayout, you just need to change AbsoluteLayout.LayoutFlags="All" to AbsoluteLayout.LayoutFlags="None"