The user can determine which page will be the main one.

валера карманов 396 Reputation points
2024-10-04T07:11:54.2166667+00:00

I want to add a setting to the application so that the user can determine which page will be loaded as the "main" when the application is launched.

Do I understand correctly that this should be defined in the "App" class, but then what about the "AppShell" class?

As I understand it, the "AppShell" class loads the application theme.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,072 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,416 Reputation points Microsoft External Staff
    2024-10-07T04:06:18.56+00:00

    Hello,

    When you create an empty MAUI app with the .NET MAUI App project template, the AppShell class will be created as well. Shell reduces the complexity of app development by providing the fundamental features that most apps require. In a Shell app, pages can be created on demand in response to navigation. And you could create Shell flyout, Shell tabs or Shell pages.

    For more details, see .NET MAUI Shell overview - .NET MAUI | Microsoft Learn

    App class is derived from Application class. In addition to loading application theme, you could also set the App lifecycle event by overriding the CreateWindow method in this class. See App lifecycle - .NET MAUI | Microsoft Learn

    I want to add a setting to the application so that the user can determine which page will be loaded as the "main" when the application is launched.

    When you open the App class, you can see   MainPage = new AppShell();, you can set the main page like the following: App.Current.MainPage = new OtherPage(); (You can create a new class that shows other pages)

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.