Hello,
App.MainPage
property is to get or set the root page of the application. You can check the source code of Shell , it's derived from Page, MainPage
is derived from Page as well. So, you can set MainPage = new MainPage()
or MainPage = new AppShell()
, the program can run normally.
In addition, MainPage
and AppShell
are both created by the default MAUI template. You can also create other pages with different types, such as FlyoutPage, NavigationPage, TabbedPage. (MainPage
is of type ContentPage)
For more details, please refer to Controls - .NET MAUI | Microsoft Learn
If you set MainPage
as the root page, you cannot implement the navigation experience. If you want to go to another page from this MainPage, you may have to invoke INavigation.PushModalAsync method.
What is the special purpose of this layer of AppShell and under what circumstances is it necessary to have AppShell?
Shell reduces the complexity of app development by providing the fundamental features that most apps require, including:
- A single place to describe the visual hierarchy of an app.
- A common navigation user experience.
- A URI-based navigation scheme that permits navigation to any page in the app.
- An integrated search handler.
For more details, please see .NET MAUI Shell overview - .NET MAUI | Microsoft Learn
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.