When would you use the NavigationPage as a MainPage?

Technology CommunityCategory: XamarinWhen would you use the NavigationPage as a MainPage?
VietMX Staff asked 3 years ago

When we want the hierarchical navigation of pages like forward or backward navigation, we may instantiate a very first page (for example: MyFirstPageXaml) wrapped into a NavigationPage and then assign it, to a MainPage property of App.cs class. For example:

public App ()
{
    MainPage = new NavigationPage (new MyFirstPageXaml ());
}

This causes the MyFirstPageXaml page instance to be pushed into the navigation stack and this page becomes the active page and acts as a Root Page of the app. Thus, it creates a stack of pages which are being pushed in LIFO (Last-In-First-Out) manner. It is recommended that we pass only “ContentPage” instances into the NavigationPage.