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/0bcfccdbc5b9e22a2a3f7e68065e50fb to your computer and use it in GitHub Desktop.
Save juucustodio/0bcfccdbc5b9e22a2a3f7e68065e50fb 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 System;
using MVVMCoffee.ViewModels;
using Sample.Models;
using Xamarin.Forms;
namespace Sample.ViewModels
{
public class FormViewModel : BaseViewModel
{
public Command PopAsyncCommand { get; }
public Command PopToRootAsyncCommand { get; }
private Customer _customer;
public Customer Customer
{
get { return _customer; }
set { SetProperty(ref _customer, value); }
}
public FormViewModel()
{
TitlePage = "FormPage";
Customer = new Customer();
PopAsyncCommand = new Command(ExecutePopAsyncCommand);
PopToRootAsyncCommand = new Command(ExecutePopToRootAsyncCommand);
}
private async void ExecutePopAsyncCommand()
{
await Navigation.PopAsync();
}
private async void ExecutePopToRootAsyncCommand()
{
await Navigation.PopToRootAsync();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment