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
<PackageReference Include="Avalonia.Labs.CommandManager" Version="12.0.2" />
<PackageVersion Include="Avalonia.Labs.CommandManager" Version="12.0.2" />
<PackageReference Include="Avalonia.Labs.CommandManager" />
paket add Avalonia.Labs.CommandManager --version 12.0.2
#r "nuget: Avalonia.Labs.CommandManager, 12.0.2"
#:package Avalonia.Labs.CommandManager@12.0.2
#addin nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2
#tool nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2
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. |
NuGet packages (15)
Showing the top 5 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. |
|
|
iPlus.gip.core.layoutengine.avui
Presentation layer and controls |
|
|
iPlus.gip.core.wpfservices.avui
Mediator for seperation of WPF and manager components |
|
|
iPlus.gip.core.reporthandler.avui
Components for rendering reports with flowdocs |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Avalonia.Labs.CommandManager:
| Repository | Stars |
|---|---|
|
ClassIsland/ClassIsland
一款功能强、可定制、跨平台,适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。
|
|
|
helix-toolkit/helix-toolkit
Helix Toolkit is a collection of 3D components for .NET.
|