Silny ToJa
Silny ToJa

Reputation: 2261

Xamarin Mater Detail Page should blocking returning to the previous page

I create aplication with Master Detail Page. I am trying do loginPage. When i run app it create master detail page and go to login page. I head read this is one way to add loginPage to Master Detail Page. But i dont know how to block possibilyty back to Master Detail Page.

This is how it looks in Master Detail Page

public MainPage()
    {
        InitializeComponent();
        Navigation.PushAsync(new LoginPage());
    }
    public MainPage(string login)
    {
        userLogin = login;
        InitializeComponent();
    }

Is this a good way to create login page in my app?

Upvotes: 1

Views: 59

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

There are two possible ways to implement it.

Solution 1:

You can block the back button of your login page .

in your login page:

public LoginPage()
{
    InitializeComponent();
    //...
    NavigationPage.SetHasBackButton(this, false);
}

Solution 2:

I suggest that you can firstly set the MainPage of App as your login page , and change it to the MasterDetailPage after login .

//login finished
App.Current.MainPage = new MainPage();

Upvotes: 3

Related Questions