I have a Xamarin Forms app that I am updating to use Maui 9. In my app, there are a couple of places where I need to change the top-level page. I was able to do this by setting the MainPage property of the app.
The release notes for Maui 9 say to override CreateWindow to set MainPage at the start of the app, and use Application.Current.Windows[0].Page to get the page, but I can see no other way of setting MainPage... can anyone suggest how I can achieve the equivalent of setting MainPage (other than overriding CreateWindow)?
Code that accesses the Application.Current.MainPage property should now access the Application.Current.Windows[0].Page property for apps with a single window.
As mentioned in documentation here. If you want to set Mainpage in runtime.You can define something like this.
Application.Current.Windows[0].Page = new NewMainPage();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With