Create a .NET MAUI App without Shell
Since the official release of .NET MAUI, it is not possible to create a new project where Visual Studio does not add a default Shell. Fortunately, there is a very simple way to get rid of it!
Shell or not Shell? It’s up to you!
When creating a new app in .NET MAUI, Visual Studio does not offer many configuration options:
But every new .NET MAUI application created with Visual Studio comes with a Shell by default. And while the Shell can reduce the complexity to develop an application, it is also a tool that any beginner must learn to master in additional to the rest.
Here is a small comparative table of the pros and cons of the Shell:
|Brings a standard application structure with a side menu or tabs, as well as a navigation system with URLs.||A bit complex at first for a beginner, may slow down the opening of the app, and is not necessary for basic cases.|
Finally, the use of Shell in a .NET MAUI project remains a personal choice and should not be enforced by Visual Studio. But then, how would you get an app without a Shell, like in the tuto My First App? Let’s have a look, it’s very simple.
Go without Shell
First of all, you need a .NET MAUI project. You can create a new one with Visual Studio, or reuse an existing project. Once your project is open in Visual Studio, delete the
AppShell class by deleting the two files AppShell.xaml and AppShell.xaml.cs.
Visual Studio will probably ask you for a confirmation. Check that the selected files are the right ones and confirm the deletion:
That’s it! All that remains is reconfiguring the application’s start page.
To do this, open the App.xaml.cs file and identify the following line of code in the class constructor:
AppShell class does not refer to anything, it must be replaced. You just have to replace it by the class associated with the page that appears first when opening the app!
For example, for all new projects, this will result into:
Now, when the application is opened, the
MainPage will be loaded first.
There you go, you don’t have to develop your application around a Shell anymore!
Now, what if you learn how to navigate from page to page without Shell?