Book Image

The MVVM Pattern in .NET MAUI

By : Pieter Nijs
Book Image

The MVVM Pattern in .NET MAUI

By: Pieter Nijs

Overview of this book

In today's fast-paced world of modern software development, teams need to be efficient, productive, and capable of rapidly adapting to changes to deliver high-quality products, making it crucial for developers to write maintainable and easy-to-test code. The MVVM Pattern in .NET MAUI helps you to thoroughly explore the Model-View-View Model (MVVM) design pattern. The chapters show you how this pattern helps in structuring code to embrace the separation of concerns, allowing for loosely coupled user interface and application logic, which ultimately empowers you to write more robust, maintainable, and testable code. The book also highlights .NET MAUI's capabilities and features, and enables you to delve into the essential components within the framework that facilitate the application of the MVVM pattern. With the help of a sample application, this definitive guide takes a hands-on approach to walk you through both the essential and advanced usages of the MVVM pattern to ensure that you successfully apply the practical aspects of the pattern to your .NET MAUI projects. By the end of this book, you’ll have gained a comprehensive understanding of the MVVM design pattern and its relevance in the context of .NET MAUI, as well as developed the skills needed to successfully apply it in practice.
Table of Contents (20 chapters)
Free Chapter
1
Part 1: Key Concepts and Components
8
Part 2: Building a .NET MAUI App Using MVVM
13
Part 3: Mastering MVVM Development

Prompts and alerts

Direct feedback and clear communication are paramount when it comes to a solid user experience. As users navigate your application and interact with various inputs, there are moments where a subtle notification or a direct prompt can make all the difference. Prompts and alerts serve as these essential tools, guiding users through their journey, ensuring they’re informed and make intentional decisions.

Showing prompts and alerts is something that is platform-specific. Luckily .NET MAUI has got us covered as they provide simple and intuitive APIs for this. On the other hand, in an MVVM scenario, displaying a prompt or alert is mostly triggered from a ViewModel, which should be framework-independent. The solution, of course, is creating an interface for this functionality that a ViewModel can talk to. On the MAUI side of things, we can easily implement this interface and register it in our DI container so the implementation gets injected into the ViewModels...