maui

How to create a NON Shell App in .NET MAUI?


We have made a decision that using Shell navigation is just a little restrictive and cumbersome and we are going to utilize our own Flyout pages which are not allowed in shell apps BUT when we move to create a new app, there is no option to create a shell/non shell app??? So we created default app then simply deleted the appshell object which seems to work BUT is this all that is required in order for us to utilize our own flyout pages?


Solution

  • Its as simple as changing MainPage = new AppShell();in App.xaml.cs, to whatever you want:

    Substitute the appropriate class name for MyFirstPage. E.g. in the Maui template, it is class MainPage, so use MainPage if you want to immediately test a new Maui project.

    Note that both these solutions involve explicitly calling new YourPageNameHere() rather than relying on Dependency Injection. This may affect code you need to write elsewhere (compared to Maui examples you'll find, which tend to rely on DI).