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" />
<PackageReference Include="Avalonia.Labs.CommandManager" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
Install package
dotnet add package package Avalonia.Labs.CommandManagerAdd 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>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)); }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>Binding
RouterCommandto 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 | Versions 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.
|