March 2018
Intermediate to advanced
192 pages
4h 4m
English
In order to move the navigation functionality from MainPage to MainViewModel, we will need to add two new Command properties—one for creating a new log entry and another for viewing the details of an existing log entry:
public class MainViewModel : BaseViewModel { // ... Command<TripLogEntry> _viewCommand; public Command<TripLogEntry> ViewCommand { get { return _viewCommand ?? (_viewCommand = new Command<TripLogEntry>(async (entry) => await ExecuteViewCommand(entry))); } } Command _newCommand; public Command NewCommand { get { return _newCommand ?? (_newCommand = new Command(async () => await ExecuteNewCommand())); } } async Task ExecuteViewCommand(TripLogEntry entry) { await NavService.NavigateTo<DetailViewModel, ...