I copied your code and just add Grid.RowSpan="3"
for the grid. And then I get the effect you want without LayoutChanged
and Appearing
.
The full xaml:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MauiApp7.MainPage" Shell.NavBarIsVisible="False"><Grid BackgroundColor="Pink"><Grid.ColumnDefinitions><ColumnDefinition Width="80" /><ColumnDefinition Width="80"/><ColumnDefinition Width="80"/><ColumnDefinition Width="80"/><ColumnDefinition Width="80"/><ColumnDefinition Width="80"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="80"/><RowDefinition Height="80"/><RowDefinition Height="80"/></Grid.RowDefinitions><Grid x:Name="gridLayoutBox" BackgroundColor="Blue" IsClippedToBounds="True" Grid.ColumnSpan="6" Grid.RowSpan="3" ></Grid></Grid></ContentPage>
And the result image:
In addition, if you want to force landscape, you can all the following code in the Page's OnHandlerChanged method or OnAppearing method.
#if ANDROIDMicrosoft.Maui.ApplicationModel.Platform.CurrentActivity.RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;#endif
And in the Portrait mode, the blue grid will be cut off beacause its width is bigger than the screen's width.