Skip to Content
Mastering Xamarin.Forms - Second Edition
book

Mastering Xamarin.Forms - Second Edition

by Ed Snider
March 2018
Intermediate to advanced content levelIntermediate to advanced
192 pages
4h 4m
English
Packt Publishing
Content preview from Mastering Xamarin.Forms - Second Edition

Updating NewEntryViewModel

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,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Xamarin.Forms - Third Edition

Mastering Xamarin.Forms - Third Edition

Ed Snider
Xamarin.Forms Projects - Second Edition

Xamarin.Forms Projects - Second Edition

Daniel Hindrikes, Johan Karlsson
Xamarin.Forms Projects

Xamarin.Forms Projects

Johan Karlsson, Daniel Hindrikes

Publisher Resources

ISBN: 9781788290265Supplemental Content