} //Binable command to fetch a saying public MainPageViewModel(SayingsAbstractModel WithModel) { DataModel = WithModel; //Hook up FetchNextSayingCommand property FetchNextSayingCommand = new Command(execute: async() => await DoFetchNextMessageCommand(), canExecute: () => ButtonEnabled); //Hook up event handler for changes in the model DataModel.PropertyChanged += OnPropertyChanged; }
} //Binable command to fetch a saying public MainPageViewModel(SayingsAbstractModel WithModel, IMainPageViewHelper pvh) { //Reference back to ViewHelper (typically the View, but might be a unit test framework) MainPageViewHelper = pvh; //Set chosen data model (this may different, depending if instantiated by the view or a unit test framework DataModel = WithModel; //Hook up event handler for changes in the model DataModel.PropertyChanged += OnPropertyChanged; //Hook up button command (typically created by the view as Command is part of Xamarin.Forms) FetchNextSayingCommand = MainPageViewHelper.CreateConcreteCommand(execute: async() => await DoFetchNextMessageCommand(), canExecute: () => ButtonEnabled); }