public YearEditPage(YearEditPageViewModel vm = null) { InitializeComponent(); //This next page does non-destructive editing - back button title reflects this NavigationPage.SetBackButtonTitle(this, "Cancel"); //Bind to the view model BindingContext = vm ?? new YearEditPageViewModel(); }
// Navigate to the About page - providing both View and ViewModel pair void NavigateToYearEditPage() { //This has a concrete reference to a view inside a VM - is this good/bad/indifferent? // Create viewmodel and pass datamodel as a parameter // NOTE that Model is a reference type YearEditPageViewModel vm = new YearEditPageViewModel(Model); //VM knows about its model (reference) // Instantiate the view, and provide the viewmodel YearEditPage nextPage = new YearEditPage(vm); //View knows about it's VM Navigation.PushAsync(nextPage); }