Book Image

Xamarin 4.x Cross-Platform Application Development - Third Edition

By : Jonathan Peppers
Book Image

Xamarin 4.x Cross-Platform Application Development - Third Edition

By: Jonathan Peppers

Overview of this book

Xamarin is a leading cross-platform application development tool used by top companies such as Coca-Cola, Honeywell, and Alaska Airlines to build apps. Version 4 features significant updates to the platform including the release of Xamarin.Forms 2.0 and improvements have been made to the iOS and Android designers. Xamarin was acquired by Microsoft so it is now a part of the Visual Studio family. This book will show you how to build applications for iOS, Android, and Windows. You will be walked through the process of creating an application that comes complete with a back-end web service and native features such as GPS location, camera, push notifications, and other core features. Additionally, you’ll learn how to use external libraries with Xamarin and Xamarin.Forms to create user interfaces. This book also provides instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features in Xamarin 4.
Table of Contents (19 chapters)
Xamarin 4.x Cross-Platform Application Development - Third Edition
About the Author
About the Reviewer
Customer Feedback

Writing the ViewModel layer

Now that we have our model layer implemented, we can move on to write the ViewModel layer. The ViewModel will be responsible for presenting each operation to the UI and offering properties to be filled out by the View layer. Other common responsibilities of this layer are input validation and simple logic to display busy indicators.

At this point, it would be a good idea to include the ServiceContainer class from the previous chapter in our XamSnap PCL project, as we will be using it through our ViewModels to interact with the Model layer. We will be using it as a simple option to support dependency injection and Inversion of Control; however, you may use another library of your preference for this.

Normally, we start off by writing a base class for all the ViewModel layers within our project. It's a good place to put some parts of the code that are used by all the subclasses, for example: notification changes, methods, or commonly used interfaces.

Place the following...