Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Xamarin.Forms

You're reading from   Mastering Xamarin.Forms Build rich, maintainable, multi-platform, native mobile apps with Xamarin.Forms

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781788290265
Length 192 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ed Snider Ed Snider
Author Profile Icon Ed Snider
Ed Snider
Roberto Hernandez Roberto Hernandez
Author Profile Icon Roberto Hernandez
Roberto Hernandez
Arrow right icon
View More author details
Toc

Creating and using platform-specific services

We have already created a service to handle navigation in the previous chapter. That custom navigation service specification was provided by the INavService interface and there is a property of that interface type in the BaseViewModel so that a concrete implementation of the service can be provided to the ViewModels as needed.

The benefit of using an interface to define platform-specific or third-party dependency services is that it can be used in an agnostic way in the ViewModels, and the concrete implementations can be provided via dependency injection. Those concrete implementations can be actual services, or even mocked services for unit testing the ViewModels, as we'll see in Chapter 8, Testing.

In addition to navigation, there are a couple of other platform-specific services our TripLog app could use to enrich its data and...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime