'Xamarin NavigationPage PushAsync Crashes

Description

Xamarin application crashes upon awaiting NavigationPage.Pushaync().
NavigationPage.Asyncpush() is called within a ButtonClicked Method.

private async void OnAboutUsClicked()
{
    var modifiedContactPage = new ModifiedContact() { BackgroundColor = ResourceColourModel.BackgroundColor };
    await Application.Current.MainPage.Navigation.PushAsync(modifiedContactPage);
}

Reproduce steps

Page.Xaml with a button that has binding property
PageViewModel which contains declaration of binding property and buttonClick event Handler

Expected behavior

To navigate to new page

Actual behavior:

Crashes with Samsung Galaxy S21 upon clicking button that contains
NavigationPage.PushAsync()

Basic Information:

Android Build:
-minimum level 21
-Target level 30
Device:
-Samsung Galaxy S21



Solution 1:[1]

Post your exception. But probably you need to write this in your App.xaml.cs constructor code:

public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
        }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marco