As mentioned in the introduction to this chapter, we created a customized navigation service, which provided an IWalkNavService
Interface class for which our WalkBaseViewModel
contained a property of that interface type, so that any implementations of the IWalkNavService
can be provided to each of the ViewModels, as required.
The benefit of using an Interface to define platform-specific services is that it can be used within the ViewModels
and the implementations of the service can be provided via dependency injection, using the DependencyService
, with those implementations being actual services, or even mocked-up services for unit testing the ViewModels, which we will be covering in
Chapter 9
, Unit Testing Your Xamarin.Forms Apps Using the NUnit and UITest Frameworks.
In addition to the navigation service, we can use a couple of other platform-specific feature services within our TrackMyWalks
app to enrich its data and user experience. In this...