TabbedPage Pop to Main page

So I have an app that has a LoginPage which is a simple NavigationPage and after the credentials are validated I have a TabbedPage as a MenuPage and when I want to log out it dosen`t do anything, here is my code:

private async void ButtonLogout_Pressed(object sender, EventArgs e) { await Navigation.PopAsync(); }

I also tried PopToRootAsync

Best Answer

Answers

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    You can change the MainPage after login .

    App.Current.MainPage = null;
    App.Current.MainPage = new TabbedPage();
    
  • marineataemilmarineataemil Member ✭✭

    @LucasZhang said:
    You can change the MainPage after login .

    App.Current.MainPage = null;
    App.Current.MainPage = new TabbedPage();
    

    It dose not work

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai
    Application.Current.MainPage = new TabbedPage();
    

    The MainPage will been changed as TabbedPage .

  • marineataemilmarineataemil Member ✭✭

    @LucasZhang said:

    Application.Current.MainPage = new TabbedPage();
    

    The MainPage will been changed as TabbedPage .

    Yea but this still dosen`t help me, if I make it my mane page how can I get back to my login page...

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    Can you share your sample which contains the issue?

  • marineataemilmarineataemil Member ✭✭

    @LucasZhang said:
    Can you share your sample which contains the issue?

    When I login I have this:
    await Navigation.PushAsync(new MenuPage());
    Then my tabbedpage has this:
    `private void TabbsPrep()
    {
    var scannerPage = new NavigationPage(new ScannerPage())
    {
    BarBackgroundColor = Color.FromHex("#5e9bff"),
    BarTextColor = Color.White
    };
    scannerPage.IconImageSource = "cameraTB.png";
    scannerPage.Title = "Scanează";

            var userPage = new NavigationPage(new UserPage())
            {
                BarBackgroundColor = Color.FromHex("#5e9bff"),
            };
            userPage.IconImageSource = "userTB.png";
            userPage.Title = "Profil";
    
            var tablePage = new NavigationPage(new MedsTabel())
            {
                BarBackgroundColor = Color.FromHex("#5e9bff"),
                BarTextColor = Color.White
            };
            tablePage.IconImageSource = "menuTB.png";
            tablePage.Title = "Meniu";
    
            Children.Add(tablePage);
            Children.Add(userPage);
            Children.Add(scannerPage);
        }`
    

    And then in my userpage I have a button action like this:
    private async void ButtonLogout_Pressed(object sender, EventArgs e) { await Navigation.PopAsync(); }

    And when its pressed it doesnt go back... I think that I understand why, but not what to do

  • marineataemilmarineataemil Member ✭✭

    @LucasZhang said:
    in login action

    Application.Current.MainPage = new MenuPage();
    

    And in logout button

    Application.Current.MainPage = new loginPage();
    

    Thank you so so much <3 <3 <3

Sign In or Register to comment.