Created
July 27, 2019 18:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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