Xamarin Forms goes to MasterDetail page after content page

I create an application using Xamarin Forms, where when the user launches the application for the first time, he is sent to the login page. After logging in, they are redirected to MasterPage, which is the MasterDetail page. However, when I try to go to the new MasterDetail page, I get only the details page, and the button showing the Master Partion is missing. The only thing that appears in the application bar is the title that I set. I now proceed to MasterPage as follows:

App.Current.MainPage = new NavigationPage(new MasterPage())
{
     Title = "Welcome " + user.firstName
};

Each other launch is not a problem, because when the user opens the application, he automatically registers them and goes directly to MasterPage, except for the cases of their first use. However, this is a very important issue for me, as it occurs when a user first uses my application, and this will be part of their first impression.

+4
source share
1 answer

When you use MasterDetailpage, you should not wrap it in Navigationpage(e.g. your sample code). Because it MasterDetailpageshould always be on top, not inside Navigationpage.

To navigate between different pages, you must wrap DetailPagefrom MasterDetailpageinside a Navigationpage.

:

var view = new MyFirstPage();
Application.Current.MainPage = new MasterPage(view);

MasterPage :

public MasterPage(Page detailpage)
{
    // Set the master-part
    Master = new MasterContentPage();

    // Set detail-part (with a navigation page)
    Detail = new NavigationPage(detailpage);
}

:

var mdp = Application.Current.MainPage as MasterDetailPage;
await mdp.Detail.Navigation.PushAsync(myNextPage);

AppNavigator, .

MasterDetailPage Xamarin.

+5

Source: https://habr.com/ru/post/1671324/


All Articles