![]() |
VOOZH | about |
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" />Directory.Packages.props
<PackageReference Include="Avalonia.Labs.CommandManager" />Project file
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.2Install as a Cake Addin
#tool nuget:?package=Avalonia.Labs.CommandManager&version=12.0.2Install as a Cake Tool
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
Install package
dotnet add package package Avalonia.Labs.CommandManager
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>
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 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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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. |
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.
|