Chapter 4. Different Cars, Same Engine

In this chapter, we will cover the following recipes:

  • Sharing code between different platforms
  • Using the dependency locator
  • Adding a third-party Dependency Injection Container
  • Architecture design with Model-View-ViewModel (MVVM) pattern
  • Using the event messenger
  • Adding localization

Introduction

In this chapter, we will learn the different approaches, Shared Projects and Portable Class Libraries (PCL), to share code across all platforms.

DependencyService is the out-of-the-box service locator from Xamarin.Forms and we will learn how to use it to resolve implementation classes for our interfaces in runtime.

Using a service locator is a solution to register the implementation classes you need to use for your abstracted ...

Get Xamarin: Cross-Platform Mobile Application Development 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.