CgdataBase.Avalonia
1.9.34
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CgdataBase.Avalonia --version 1.9.34
NuGet\Install-Package CgdataBase.Avalonia -Version 1.9.34
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="CgdataBase.Avalonia" Version="1.9.34" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CgdataBase.Avalonia" Version="1.9.34" />
<PackageReference Include="CgdataBase.Avalonia" />
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 CgdataBase.Avalonia --version 1.9.34
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CgdataBase.Avalonia, 1.9.34"
#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 CgdataBase.Avalonia@1.9.34
#: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=CgdataBase.Avalonia&version=1.9.34
#tool nuget:?package=CgdataBase.Avalonia&version=1.9.34
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CgdataBase.Avalonia
一组面向 Avalonia 11 的通用控件能力与工具类,包含样式主题、常用转换器、以及用于“记忆 UI 状态”的控制器(Window / DataGrid / Grid)。
依赖与目标框架
- 目标框架:
net6.0/net8.0/net10.0 - 主要依赖:
Avalonia 11.3.2、Avalonia.Controls.DataGrid 11.3.2、Avalonia.Desktop 11.3.2 - 另外依赖:项目引用 CgdataBase.Core
引用方式
方式 1:项目引用(仓库内开发推荐)
- 在你的应用项目中引用 CgdataBase.Avalonia.csproj
方式 2:NuGet(若已发布)
dotnet add package CgdataBase.Avalonia
快速开始
1)在 App.axaml 中引入主题样式
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="YourApp.App">
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://CgdataBase.Avalonia/Styles/Theme1.axaml" />
</Application.Styles>
</Application>
主题入口文件: Theme1.axaml。
2)Window:自动保存/恢复窗口大小与状态
using Avalonia.Controls;
using CgdataBase;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
WindowController.UpdateWindowConfig(this, GetType());
}
}
实现位于 WindowController。
3)DataGrid:记忆列宽
using Avalonia.Controls;
using CgdataBase.Avalonia.Controllers;
DataGridController.UpdateDataGridConfig(this, TaskList);
实现位于 DataGridController。
4)Grid:记忆行高/列宽(Row/ColumnDefinitions)
using Avalonia.Controls;
using CgdataBase.Avalonia.Controllers;
GridController.AttachedProperties(this, ContentGrid);
实现位于 GridController。
5)FocusBehavior:通过绑定控制焦点
该行为使用 AttachedProperty<int>:当绑定值变化时,将控件聚焦,并在 TextBox 上把光标移动到末尾。
<TextBox
xmlns:hp="clr-namespace:CgdataBase.Avalonia.Helpers;assembly=CgdataBase.Avalonia"
hp:FocusBehavior.IsFocused="{Binding KeywordFocused}"
Text="{Binding Keyword}" />
实现位于 FocusBehavior。
6)常用转换器(Converters)
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cvt="clr-namespace:CgdataBase.Avalonia.Converters;assembly=CgdataBase.Avalonia">
<Window.Resources>
<cvt:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
<cvt:FileSizeConverter x:Key="FileSizeConverter" />
</Window.Resources>
<TextBlock Text="{Binding Speed, Converter={StaticResource EnumToDescriptionConverter}}" />
<TextBlock Text="{Binding FileSize, Converter={StaticResource FileSizeConverter}}" />
</Window>
相关文件位于 Converters。
配置存储说明
Window / DataGrid / Grid 的状态保存与读取依赖 UISettings(来自 CgdataBase.Core)。默认会以“类型 + 控件名/固定键名”的方式记录配置。
构建
dotnet build .\CgdataBase.Avalonia\CgdataBase.Avalonia.csproj -c Release
仓库内示例应用: CgdataBaseAvaloniaDemo
License
MIT
| 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.
-
net10.0
- Avalonia (>= 12.0.4)
- Avalonia.Controls.DataGrid (>= 12.0.0)
- Avalonia.Desktop (>= 12.0.4)
- CgdataBase.Core (>= 1.9.34)
-
net8.0
- Avalonia (>= 12.0.4)
- Avalonia.Controls.DataGrid (>= 12.0.0)
- Avalonia.Desktop (>= 12.0.4)
- CgdataBase.Core (>= 1.9.34)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 12.0.0 | 94 | 6/23/2026 | |
| 11.1.3 | 296 | 8/14/2024 | |
| 11.1.2 | 213 | 8/7/2024 | |
| 11.1.0 | 222 | 7/24/2024 | |
| 11.0.10.5 | 239 | 6/27/2024 | |
| 11.0.10.4 | 223 | 6/26/2024 | |
| 11.0.10.3 | 226 | 6/5/2024 | |
| 11.0.10.2 | 228 | 5/21/2024 | |
| 11.0.10.1 | 243 | 3/29/2024 | |
| 11.0.10 | 255 | 3/10/2024 | |
| 11.0.9 | 247 | 2/21/2024 | |
| 11.0.7 | 257 | 1/27/2024 | |
| 11.0.6 | 333 | 12/7/2023 | |
| 11.0.5 | 285 | 11/2/2023 | |
| 11.0.4 | 273 | 10/17/2023 | |
| 11.0.3 | 284 | 8/14/2023 | |
| 11.0.0 | 320 | 7/6/2023 | |
| 1.9.34 | 90 | 6/23/2026 | |
| 1.9.6 | 161 | 3/20/2026 | |
| 1.9.3 | 144 | 1/6/2026 |
Loading failed