Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for MAUI landscape mode grid issues

$
0
0

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:

enter image description here

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.


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>