The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
The CommandFactory class provides a unified approach to creating new Command, AsyncCommand, and AsyncValueCommand objects
Detailed Design
CommandFactory.Comand.shared.cs
public static partial class CommandFactory
{
public static Command Create(Action execute) => new Command(execute);
public static Command Create(Action execute, Func<bool> canExecute) => new Command(execute, canExecute);
public static Command Create(Action<object> execute) => new Command(execute);
public static Command Create(Action<object> execute, Func<object, bool> canExecute) => new Command(execute, canExecute);
public static Command<T> Create<T>(Action<T> execute) => new Command<T>(execute);
public static Command<T> Create<T>(Action<T> execute, Func<T, bool> canExecute) => new Command<T>(execute, canExecute);
}
CommandFactory
Summary
The CommandFactory class provides a unified approach to creating new Command, AsyncCommand, and AsyncValueCommand objects
Detailed Design
CommandFactory.Comand.shared.cs
CommandFactory.IAsyncCommand.shared.cs
CommandFactory.IAsyncValueCommand.shared.cs
Usage Syntax
XAML Usage
N/A
C# Usage
Drawbacks
CommandFactory
augments bothAsyncCommand
andAsyncValueCommand
, both of which are not being included in the .NET MAUI Toolkit:Alternatives
MVVM Toolkit AsyncRelayCommand
https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/asyncrelaycommand