O'Reilly logo

Mastering Xamarin UI Development - Second Edition by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and using platform-specific services within your app

As mentioned in the introduction to this chapter, we created a customized NavigationService Interface and Class and then updated our BaseViewModel to include a property reference to our INavigationService so that each of our ViewModels can reference it.

The benefits of using an interface and class to define a platform-specific service is that they can be used within each of your ViewModels. Then, the implementations of the service can be provided using dependency injection.

This is achieved by declaring the DependencyService meta tag, with each of those implementations being actual services, or even Mock services that can be used to unit test your ViewModels, which we will be covering ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required