Hi,
I have a ContentPage being rendered by calling Navigation.PushAsync. The OnAppearing event is not firing when the AddLocationPage is loaded/rendered.
Any assistance would be appreciated! I've been sitting with this for the last two days.
public partial class App : Xamarin.Forms.Application { public App() { InitializeComponent(); MainPage = new NavigationPage(new MainTabbedPage()); // MainTabbedPage : Xamarin.Forms.TabbedPage } }
-- This ContentPage sits within a Xamarin.Forms.TabbedPage as the first TabbedPage.Children <mainTabs:LocationsPage /> [XamlCompilation(XamlCompilationOptions.Compile)] public partial class LocationsPage : ContentPage { public LocationsPage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); } private async void OnListItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { await Navigation.PushAsync(new AddLocationPage { BindingContext = e.SelectedItem as LocationDbModel }); } }
[XamlCompilation(XamlCompilationOptions.Compile)] public partial class AddLocationPage : ContentPage { public AddLocationPage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); } // ISSUE: OnAppearing event not being called // This page gets invoked/pushed using Navigation.PushAsync from LocationsPage.OnListItemSelected() protected override void OnAppearing() { base.OnAppearing(); var binddingContextData= (LocationDbModel)BindingContext; if ((binddingContextData == null || binddingContextData.Latitude == 0) && binddingContextData.Longitude == 0) return; // removed for brevity - This code needs to be executed when the page is loaded. } }
I made a test demo with TabbedPage
, I can execute the OnAppearing
method. Here is running GIF.
I update my demo, you can test it in your VS, If you can get the same result like us.
If you can get the same result, please update your nuget packages to the latest. Then make a test.
Answers
I made a test demo with
TabbedPage
, I can execute theOnAppearing
method. Here is running GIF.I update my demo, you can test it in your VS, If you can get the same result like us.
If you can get the same result, please update your nuget packages to the latest. Then make a test.