Skip to Main Content
Xamarin.Forms Projects
book

Xamarin.Forms Projects

by Johan Karlsson, Daniel Hindrikes
December 2018
Intermediate to advanced content levelIntermediate to advanced
416 pages
10h 30m
English
Packt Publishing
Content preview from Xamarin.Forms Projects

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 ...
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

Xamarin.Forms Projects - Second Edition

Xamarin.Forms Projects - Second Edition

Daniel Hindrikes, Johan Karlsson
Xamarin Blueprints

Xamarin Blueprints

Michael Williams
Xamarin.Forms Solutions

Xamarin.Forms Solutions

Gerald Versluis, Steven Thewissen

Publisher Resources

ISBN: 9781789537505Supplemental Content