Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created January 14, 2021 16:28
Show Gist options
  • Save sjehutch/ebf6af8dec76d44b4b3caefa12633acc to your computer and use it in GitHub Desktop.
Save sjehutch/ebf6af8dec76d44b4b3caefa12633acc to your computer and use it in GitHub Desktop.
Page Navigation Xamarin Forms
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace NewYoutube.Services
{
public class PageService : IPageService
{
public async Task<bool> DisplayAlert(string title, string message, string ok, string cancel)
{
return await MainPage.DisplayAlert(title, message, ok, cancel);
}
public async Task DisplayAlert(string title, string message, string ok)
{
await MainPage.DisplayAlert(title, message, ok);
}
public async Task<Page> PopAsync()
{
return await MainPage.Navigation.PopAsync();
}
public async Task PushAsync(Page page)
{
await MainPage.Navigation.PushAsync(page);
}
public async Task PushModalAsync(Page page)
{
await MainPage.Navigation.PushModalAsync(page);
}
private Page MainPage
{
get { return Application.Current.MainPage; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment