Avalonia.Labs.CommandManager 12.0.2

Prefix Reserved
dotnet add package Avalonia.Labs.CommandManager --version 12.0.2
                    
NuGet\Install-Package Avalonia.Labs.CommandManager -Version 12.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Avalonia.Labs.CommandManager" Version="12.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Avalonia.Labs.CommandManager" Version="12.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Avalonia.Labs.CommandManager" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Avalonia.Labs.CommandManager --version 12.0.2
                    
#r "nuget: Avalonia.Labs.CommandManager, 12.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Avalonia.Labs.CommandManager@12.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2
                    
Install as a Cake Tool

Avalonia.Labs.CommandManager

Experimental WPF-like implementation of RoutedCommand.

the currently supported flow is this:

sequenceDiagram
    participant RotendCommand
    participant View
    participant CommandManager
    participant ViewModel
    participant TopLevel
    TopLevel->>CommandManager: Got Focus
    CommandManager->>RotendCommand: Raise CanExecuteChanged
    RotendCommand->>View: Raise CommandManager.CanExecuteEvent
    View->>CommandManager: Raise CommandManager.CanExecuteEvent
    CommandManager->>ViewModel: ICommand.CanExecute
    CommandManager->>RotendCommand: Handle=True
    RotendCommand->>View: Raise CommandManager.ExecuteEvent
    View->>CommandManager: Raise CommandManager.ExecuteEvent
    CommandManager->>ViewModel: ICommand.Execute

Get Started

  1. Install package

    dotnet add package package Avalonia.Labs.CommandManager
    
  2. Add XML Namespace

    <UserControl xmlns="https://github.com/avaloniaui"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:lab="using:Avalonia.Labs.Catalog"
    +             xmlns:rc="using:Avalonia.Labs.Input"
                mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                xmlns:viewModels="using:Avalonia.Labs.Catalog.ViewModels"
                x:Class="Avalonia.Labs.Catalog.Views.RouteCommandView"
                x:DataType="viewModels:RouteCommandViewModel"
                HorizontalContentAlignment="Stretch"
                VerticalContentAlignment="Stretch"
                >
                ...
    </UserControl>
    
  3. Define your's RouterCommands

    public static class ApplicationCommands
    {
        public readonly static RoutedCommand Open = new RoutedCommand(nameof(Open));
        public readonly static RoutedCommand Save = new RoutedCommand(nameof(Save));
    }
    
  4. Assign your RotedCommand

            <UniformGrid Columns="2"
                        Grid.Column="2">
                <Button Content="Open"
                        Command="{x:Static lab:ApplicationCommands.Open}"
                        CommandParameter="{Binding .}"/>
                <Button Content="Save"
                        Command="{x:Static lab:ApplicationCommands.Save}"
                        CommandParameter="{Binding .}"/>
            </UniformGrid>
    
  5. Binding RouterCommand to yours ViewModel

    <UserControl xmlns="https://github.com/avaloniaui"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:lab="using:Avalonia.Labs.Catalog"
                xmlns:rc="using:Avalonia.Labs.Input"
                mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                xmlns:viewModels="using:Avalonia.Labs.Catalog.ViewModels"
                x:Class="Avalonia.Labs.Catalog.Views.RouteCommandView"
                x:DataType="viewModels:RouteCommandViewModel"
                HorizontalContentAlignment="Stretch"
                VerticalContentAlignment="Stretch"
                >
    <rc:CommandManager.CommandBindings>
        <rc:CommandBinding Command="{x:Static lab:ApplicationCommands.Open}" ExecutingCommand="{Binding Open}" />
        <rc:CommandBinding Command="{x:Static lab:ApplicationCommands.Save}" ExecutingCommand="{Binding Save}" />
    </rc:CommandManager.CommandBindings>
    ...
    </UserControl>
    

You can view full sample here.

Todo

  • CommandTarget (requires modification in Avalonia).
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Avalonia.Labs.CommandManager:

Package Downloads
ClassIsland.Core

ClassIsland 应用核心依赖库,包括 ClassIsland 封装的一些常用控件和方法。

HelixToolkit.Avalonia.SharpDX

Helix Toolkit is a collection of 3D components for .NET. This package is based on Avalonia UI and SharpDX.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Avalonia.Labs.CommandManager:

Repository Stars
helix-toolkit/helix-toolkit
Helix Toolkit is a collection of 3D components for .NET.
Version Downloads Last Updated
12.0.2 0 4/23/2026
12.0.0 117 4/8/2026
12.0.0-rc1 101 3/24/2026
11.3.1 623 8/14/2025
11.3.0 15,523 5/21/2025
11.2.0 912 10/20/2024
11.1.0 521 8/5/2024
11.0.10.1 389 3/19/2024
11.0.10 237 3/18/2024