Rg.plugins.popup: [Android] OnAppearing is not called on main page when popup is popped

Created on 31 May 2016  路  6Comments  路  Source: rotorgames/Rg.Plugins.Popup

After calling Navigation.PopPopupAsync, I'm expecting OnAppearing to be called on the main page. Unfortunately, it does not seem to be triggered.
This issue is very similar to https://bugzilla.xamarin.com/show_bug.cgi?id=32615 , however the bug with modal pages on Xamarin.Forms has been fixed.
Any idea for a fix or a workaround ?

Thanks

(Tested with Xamarin.Forms 2.2.0.45)

question

Most helpful comment

Or maybe this is the expected behaviour ?

Anyway, a simple workaround consists in adding mainpage's OnAppearing to the Disappearing event of the popup, when creating the popup:

var popup = new PopupPage();
popup.Disappearing += (sender, e) => { this.OnAppearing(); };
await Navigation.PushPopupAsync(popup);

All 6 comments

Or maybe this is the expected behaviour ?

Anyway, a simple workaround consists in adding mainpage's OnAppearing to the Disappearing event of the popup, when creating the popup:

var popup = new PopupPage();
popup.Disappearing += (sender, e) => { this.OnAppearing(); };
await Navigation.PushPopupAsync(popup);

@balmeras Hi friend. Yes, OnAppearing don't calling.

This is for two reasons.

  1. Main page, does not disappear completely, the life cycle of main page does not stop when you open the popup page. On the main page you can still work even with an open popup page.
  2. Xamarin Forms does not allow you to send events and OnAppearing OnDisappearing of external code. I do not want to use reflection.

All right, it makes sense.
Thanks for your answer and for this plugin :)

@tranb3r thank you very much for your workaround it works fine. I hope that it is not navigation violation or whatsoever :)

@EmilAlipiev @tranb3r I can send OnAppearing and OnDisappearing events from external code with the new version Xamarin.Forms. Maybe I add OnAppearing and OnDisappearing events in new version of plugin

@EmilAlipiev @tranb3r P.S. But a problem exists. Popup can be visible even if pages behind it will be hidden and PopupNavigation will not be able to send OnAppearing event because Xamarin.Forma.Navigation will have already sent it .

Was this page helpful?
0 / 5 - 0 ratings