Search code examples
c#mauimaui-blazormaui-windows

How hide MAUI window?


can you tell me if it is possible to hide the window in MAUI? For example, I want the window containing the MainPage to be hidden when launching the application and a second window for authorization to be displayed. After successful login, the authorization window closes and the main window becomes visible

The root of my question lies in the fact that if I define the MainPage in App.xaml.cs as a LoginPage, then later I cannot reassign it because the setter of this property works only if the MainPage is null. I decided to split the MainPage and LoginPage in different windows and now I want to hide the window containing the MainPage until the user logs in. The application is planned to be used only under Windows


Solution

  • If I define the MainPage in App.xaml.cs as a LoginPage, then later I cannot reassign it because the setter of this property works only if the MainPage is null.

    After logging successfully, you can use App.Current.MainPage = new MainPage();. Or you can use MainPage = new NavigationPage(new LoginPage()); And then call await Navigation.PushAsync(new MainPage()); after successful login. For hiding the window, you can refer this AppWindow.Hide Method method;