Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created November 21, 2019 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/77381f63c1ff85d0a28f52282ffa60f1 to your computer and use it in GitHub Desktop.
Save icebeam7/77381f63c1ff85d0a28f52282ffa60f1 to your computer and use it in GitHub Desktop.
DemoCamara: MenuViewModel.cs
using System;
using System.Windows.Input;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace DemoCamara.ViewModels
{
public class MenuViewModel : BaseViewModel
{
public ICommand NavigateCommand { private set; get; }
public INavigation Navigation { get; set; }
public MenuViewModel(INavigation navigation)
{
Navigation = navigation;
NavigateCommand = new Command<Type>(async (pageType) => await Navigate(pageType));
}
async Task Navigate(Type pageType)
{
var page = (Page)Activator.CreateInstance(pageType);
await Navigation.PushAsync(page);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment