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

How can we detect if the Navigation object has a Pushed page?

$
0
0

I've got a MasterDetailPage.

Within the MasterDetailPage:

Detail = new NavigationPage(new ModulePage());
Master = new MainMenu();

Within the ModulePage I use App.Navigation.PushAsync(new SegmentPage()); to navigate the the selected segment.
I also use the MessagingCenter to subscribe to module updates sent from the MainMenu

Within the MainMenu, I update the message that I send a message to the MessagingCenter when the user selects a Module.


Now that the stage is set, the problem I'm running into is if the user has navigated to the Module and THEN navigated to the Segment within the Module, the SegmentPage is on top of the ModulePage.

I need to be able to PopAsync the SegmentPage if it exists, but do nothing if it doesn't.

Right now the behavior is that when the Module message is sent, it updates the view behind the Segment, and the actual View doesn't change until the user presses the < back button.


Ideally it would be nice to be able to do something like this

App.Navigation.PushAsync(new SegmentPage(), "segment");
//
App.Navigation.PopNamedAsync("segment");

where PopNamedAsync will only pop a page if it exists in the stack.


Until this perfect world becomes a reality, is there a different way to detect if there's a page on the navigation stack, and only pop if it exists?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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