Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created July 27, 2019 18:06
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 juucustodio/c9581edd05b40f09d3e6312af4bcc3c4 to your computer and use it in GitHub Desktop.
Save juucustodio/c9581edd05b40f09d3e6312af4bcc3c4 to your computer and use it in GitHub Desktop.
Example of how to work with MVVM pattern using the MVVMCoffee nuget package - http://julianocustodio.com/mvvmcoffee
using MVVMCoffee.ViewModels;
using Xamarin.Forms;
namespace Sample.ViewModels
{
public class MainViewModel : BaseViewModel
{
public Command PushAsyncToFormCommand { get; }
public Command SetRootFormCommand { get; }
public MainViewModel()
{
TitlePage = "MainPage";
PushAsyncToFormCommand = new Command(ExecutePushAsyncToFormCommand);
SetRootFormCommand = new Command(ExecuteSetRootFormCommand);
}
private async void ExecutePushAsyncToFormCommand()
{
await Navigation.PushAsync<FormViewModel>(false);
}
private async void ExecuteSetRootFormCommand()
{
await Navigation.SetRootAsync<FormViewModel>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment