6

Introducing Dependency Injection and Platform-Specific Services

In the last chapter, we introduced navigation and Shell in .NET Multi-platform App UI (.NET MAUI), and we completed the navigation design of our app. We improved two interfaces, IDataStore and IUserService, to separate the model from the view and view model. In the current code, we used the DependencyService class to decouple the interface implementations. In this chapter, we will refine our design using dependency injection (DI) to replace the DependencyService class. There is a built-in service to support DI in .NET MAUI. With the help of DI, we can refine our design and decouple the dependencies in a more elegant way.

We will cover the following topics in this chapter:

  • A quick ...

Get .NET MAUI Cross-Platform 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.