Creating a navigation service

In a typical multi-platform mobile app architecture, one would have to implement a platform-specific navigation service for each platform the app supports. In our case, Xamarin.Forms has already done this, so we will simply implement a single navigation service that extends the Xamarin.Forms navigation abstraction so that we can perform ViewModel-to-ViewModel navigation.

The first thing we will need to do is define an interface for our navigation service that will define its methods. We will start with an interface so that the service can be added to ViewModels via constructor injection, which we'll dive into in Chapter 4, Platform-Specific Services and Dependency Injection, and we can easily provide alternative ...

Get Mastering Xamarin.Forms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.