Building the ViewModel

We will start by creating the ViewModel, which will handle what will happen when a user taps one of the buttons. Let's set this up by going through the following steps:

  1. Create a new class called MainViewModel in the ViewModels folder.
  2. Add ViewModel as a base class for MainViewModel.
  3. Create a private field of the IClassifier type and call it classifier.
  4. Create a constructor that has the IClassifier as a parameter.
  5. Set the value of the classifier field to the value of the parameter in the constructor, as shown in the following code:
using System.IO;using System.Linq;using System.Windows.Input;using HotdogOrNot.Models;using HotdogOrNot.Views;using Xamarin.Forms; public class MainViewModel : ViewModel{    private IClassifier ...

Get Xamarin.Forms Projects now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.