Skip to content

Instantly share code, notes, and snippets.

@julesx

julesx/NavHelper.cs

Created Sep 27, 2017
Embed
What would you like to do?
public static class NavHelper
{
public static Page CurrentPage => Application.Current.MainPage;
private static INavigation Navigation => CurrentPage.Navigation;
public static async Task PopAsync()
{
var masterDetailPage = CurrentPage as MasterDetailPage;
if (masterDetailPage != null)
await masterDetailPage.Detail.Navigation.PopAsync();
else
await Navigation.PopAsync();
}
public static async Task PopModalAsync()
{
var masterDetailPage = CurrentPage as MasterDetailPage;
if (masterDetailPage != null)
await masterDetailPage.Detail.Navigation.PopModalAsync();
else
await Navigation.PopModalAsync();
}
public static async Task PushModalAsync(Page page)
{
var masterDetailPage = CurrentPage as MasterDetailPage;
if (masterDetailPage != null)
await masterDetailPage.Detail.Navigation.PushModalAsync(page);
else
await Navigation.PushModalAsync(page);
}
public static async Task PushAsync(Page page)
{
var masterDetailPage = CurrentPage as MasterDetailPage;
if (masterDetailPage != null)
await masterDetailPage.Detail.Navigation.PushAsync(page);
else
await Navigation.PushAsync(page);
}
}
@asad-naeem

This comment has been minimized.

Copy link

@asad-naeem asad-naeem commented Oct 18, 2019

it made my life easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.