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.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer General Getting Started Hybrid iOS macOS Made Easy MVVM NuGet Preview Toolkit Visual Studio VS Code What's New Windows Xamarin Xamarin.Forms

MVVM Toolkit v8.4: Custom Access Modifiers for Partial Properties – How To

This article is part of the MVVM – Made Easy series, with a focus on the initial preview release of v8.4 of the CommunityToolkit.Mvvm (aka Microsoft MVVM Toolkit) NuGet package, which includes support for Partial Properties.

Update as of Dec 2024: The v8.4 stable release is now available. For further details, please refer to this blog post.

Here are the links to other articles in this series.

Support for Partial Properties is one of most sought after features in the MVVM toolkit as it allows to define custom access modifier for property accessors and makes code more readable. The need for an analyzer to track the usage of a field instead of a (generated) property is no longer necessary.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Deep Dive Desktop Developer General Hybrid iOS macOS Made Easy Mobile MVVM Visual Studio VS Code Web Windows Xamarin Xamarin.Forms

Using MVVM Toolkit for Messaging in .NET MAUI Blazor Hybrid Apps

This is the third article in the MVVM Made Easy series with a focus on Messaging in .NET MAUI and Blazor Hybrid apps.

Here are the links to other articles in this series.

Although the fundamentals remain the same, the preceding articles were published after the initial version of the MVVM Toolkit, and a lot has transpired since then. An updated article is being prepared and published soon.

Blazor Hybrid represents an exemplary integration of cross-platform .NET MAUI and the Blazor components.

It facilitates the utilization of C# expertise in the development of various applications, including those for Desktop, Mobile, and Web platforms.

However, there are instances when these disparate components must communicate with one another for the integration to function effectively.

Whenever the necessity arises to facilitate communication between loosely coupled components, messaging represents the most effective solution.

Categories
.NET .NET 8 .NET MAUI C# Code Deep Dive Desktop Developer General Learn Made Easy Mobile MVVM Xamarin

MVVM – Made Easy with Microsoft MVVM Toolkit – Part 2

This article is the second part of this MVVM – Made Easy series. The first part of this article, covering the basics, is linked here.

As seen in the first part, INotifyPropertyChanged (INPC) is the interface that defines the event which raises the notification whenever the value of the property gets changed.

Categories
.NET MAUI Deep Dive Desktop Developer Getting Started Made Easy Mobile MVVM Xamarin

MVVM – Made Easy with Microsoft MVVM Toolkit – Part 1

The Model-View-ViewModel (MVVM) is a software design pattern that is structured to separate program (business) logic and user interface controls. The main advantage is, that the program logic is fully unit-testable as it functions independently of the UI controls (loosely coupled). It is very popular among the developers of XAML-based UI frameworks such as WPF, UWP, Xamarin.Forms, .NET MAUI, WinUI, and even other 3rd Party frameworks such as Uno.