Skip to content

Instantly share code, notes, and snippets.

@julesx
Created September 27, 2017 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julesx/4a3b68ef7f7eda8572ae5755e3665d47 to your computer and use it in GitHub Desktop.
Save julesx/4a3b68ef7f7eda8572ae5755e3665d47 to your computer and use it in GitHub Desktop.
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
Copy link

it made my life easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment