Categories
.NET .NET 8 .NET 9 .NET MAUI Android Behaviors Blazor C# Code Desktop Developer Hybrid iOS MVVM NuGet Quick Fix Toolkit Web Windows Xamarin Xamarin.Forms

.NET MAUI Community Toolkit v10.0: How to Fix BindingContext Issues with Behaviors

Yesterday marked the official release of the highly anticipated .NET MAUI Toolkit (CommunityToolkit.Maui) package v10.0, introducing native support for .NET 9.

Though it is the extended arm of .NET MAUI app development, for newcomers, this officially supported toolkit offers a comprehensive collection of essential components—such as Alerts, Behaviors, Converters, Extensions, Layouts, and Views—that are crucial for developing real-world apps.

This new release has some breaking changes, with the most notable being aligning with the design change introduced in .NET MAUI 9, where Behaviors no longer automatically inherit the BindingContext of their parent (a major shift from the original Xamarin.Forms design).

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Behaviors Blazor C# Code Commands Desktop Developer General Hybrid iOS Made Easy Mobile MVVM Toolkit Windows Xamarin Xamarin.Forms

Handling UI Events with MVVM Commands in .NET MAUI using EventToCommandBehavior

This article is part of the MVVM – Made Easy series, focusing on handling UI events with ViewModel commands.

This series comprises articles that provide insights into working with the MVVM design pattern, to make it a delightful experience. All the articles in this series can be accessed from here – MVVM – Made Easy

The View serves as the user interface, while the ViewModel is composed of Properties and Commands that encapsulate the underlying logic. This architectural layering offers the distinct advantage of enabling independent development and testing of both components. Data Binding functions as the cohesive element that interlinks these two layers.

An event represents a significant mechanism for notifying state changes, such as a button click, to other components that have a vested interest in the occurrence.

The receiver component is capable of responding to the event by subscribing to it through a method whose signature corresponds with the delegate of the event ensuring type safety. And that method is generally referred to as an event handler.

However, the challenge emerges during the testing of the ViewModel, as the event is closely intertwined with the View. Business logic can’t be independently tested.