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

NavigationPage.Pushed isn't being raised on Navigate.PushModalAsync calls...

$
0
0

... and similarly, NavigationPage.Popped isn't being raised on Navigate.PopModalAsync calls.

In my mind modal navigation is a visual implementation detail, so I would expect the Pushed and Popped events to be raised regardless of navigation modality.

However, it appears they are not being raised when navigating modally. In fact, it's clear from a quick look at the code in ILSpy that although the INavigation interface specifies the Push/PopModalAsync methods, and the private NavigationProxy class provides virtual methods for both OnPush/PopAsync and OnPush/PopModalAsync, the private NavigationPage.NavigationImpl implementation (which defers ultimately to NavigatePage methods, which is where the Pushed and Popped events are actually raised) only overrides OnPush and OnPop, and not their async siblings. NavigationPage in fact completely lacks PushModalAsync and PopModalAsync implementations which might be a good place to raise Pushed and Popped on modal navigation, as its extant PushAsync and PopAsync methods already do.

Xamarin folks, is this an oversight or by design? If the latter, how are we able to catch / monitor / cancel(?) modal navigation events, not just from calls to Navigation methods, but more importantly from the hardware back button on devices that have those?

Any answers / insights / corrections welcome, thanks!


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>