March 2018
Intermediate to advanced
192 pages
4h 4m
English
In Chapter 2, MVVM and Data Binding, we added SaveCommand to NewEntryViewModel, but once the SaveCommand executed, nothing occurred. Once SaveCommand performs its logic to save the new log entry, it should navigate the user back to the previous page. We can accomplish this by updating the execute Action of SaveCommand to call the GoBack method in the navigation service that we created in the last section:
public class NewEntryViewModel : BaseViewModel{ // ... Command _saveCommand; public Command SaveCommand { get { return _saveCommand ?? (_saveCommand = new Command(async () => await ExecuteSaveCommand(), CanSave)); } } // ... async Task ExecuteSaveCommand() { var newItem = new TripLogEntry { Title = Title,