How to change the size between Pages in Windows Desktop app

BM Tam 0 Reputation points

I am using below environment to create windows desktop app + Maui / Net 7 + Windows 10

I need to set the size for each screen, for example: + LoginPage : width (400), height(650) + MenuPage : width (600), height(800)

I have referred to the link creation settings below:

However, for "LoginPage" it is OK but "MenuPage" gives an error: "Object reference not set to an instance of an object."

Below is my "MenuPage" source and the error that occurs at the line "this.Window.Width = width;"

public partial class Index : ContentPage

   protected override void OnAppearing()

             const int width = 800;
             const int height = 600;

             this.Window.Width = width;
             this.Window.Height = height;
         catch (Exception ex)

I want to ask is there any way to set the size for each page?

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
1,862 questions
{count} votes

1 answer

Sort by: Most helpful
  1. BM Tam 0 Reputation points

    I fixed it by replacing "this.Windows" with "Shell.Current.Window"

    The cause is unknown but may be due to application problems:

    await Shell.Current.GoToAsync...