Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to navigate back to the MainPage? (PushAsync is not supported globally on Android... error)

$
0
0

Hi. In the Android Emulator (Nexus 5 image based, API 27) I got this error message:
PushAsync is not supported globally on Android, please use a NavigationPage.

If I know the following is the correct code.

My Code is the following:

public partial class CartPage : ContentPage
    {
        public CartPage()
        {
            InitializeComponent();
            CancelButton.Clicked += CancelButton_Clicked;
            FinischButton.Clicked += PayButton_Clicked;
        }

        async private void FinischButton_Clicked(object sender, EventArgs e)
        {
            Cart.FinshOrder();
            await Navigation.PushAsync(new NavigationPage(new MainPage()));
        }

        async private void CancelButton_Clicked(object sender, EventArgs e)
        {
            Cart.RemoveItems();
            await Navigation.PushAsync(new NavigationPage(new MainPage()));
        }
    }

I want that if the user click on the Cancel or Pay button then I want to navigate him back to the MainPage.


Viewing all articles
Browse latest Browse all 77050

Trending Articles