VOOZH about

URL: https://www.nuget.org/packages/CgdataBase.WPF/

⇱ NuGet Gallery | CgdataBase.WPF 1.9.34




CgdataBase.WPF 1.9.34

dotnet add package CgdataBase.WPF --version 1.9.34
 
 
NuGet\Install-Package CgdataBase.WPF -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.WPF" Version="1.9.34" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CgdataBase.WPF" Version="1.9.34" />
 
Directory.Packages.props
<PackageReference Include="CgdataBase.WPF" />
 
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 CgdataBase.WPF --version 1.9.34
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CgdataBase.WPF, 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.WPF@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.WPF&version=1.9.34
 
Install as a Cake Addin
#tool nuget:?package=CgdataBase.WPF&version=1.9.34
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

CgdataBase.WPF

一个轻量级的 WPF 基础库,基于 提供更贴近桌面端 UI 的能力:常用转换器、控件/行为、窗口与系统集成辅助,以及一套可直接复用的基础样式资源。

安装

Install-Package CgdataBase.WPF
dotnet add package CgdataBase.WPF

目标框架

  • net6.0-windows / net8.0-windows / net10.0-windows

包含内容

Behaviors / Helpers(附加属性与 UI 辅助)

  • FocusBehavior:提供 IsFocused 附加属性,用于在 XAML/MVVM 中触发控件聚焦,并支持 TextBox 光标定位到末尾。
  • UIElementHelper:常用 UI 相关的辅助方法(见 )。

Controllers(桌面端控制类)

  • AsyncObservableCollection<T>:支持跨线程更新的 ObservableCollection<T>(自动切回创建时的 SynchronizationContext),避免后台线程更新集合导致 UI 异常。
  • WindowController:窗口显示信息(尺寸/位置/状态)加载与自动保存;提供 EscToExitShowWindow 等常用窗口行为。
  • AutoStartController:写入/删除 HKCU\Software\Microsoft\Windows\CurrentVersion\Run 实现开机自启配置。
  • ClipboardEx / ClipboardFormat:基于 Win32 API 的剪贴板增强操作与格式常量。
  • ListViewControllerRegistryController:ListView 与注册表相关的常用封装(见 )。

Controls(可复用控件)

  • TitleTextBox:带标题区域的 TextBox。
  • ToggleButton:自定义 ToggleButton 样式/行为封装。
  • VirtualizingWrapPanel:支持虚拟化的 WrapPanel(实现 IScrollInfo),适合大量数据项的“平铺”场景。
  • WpfChart:基于 Grid 的柱形图控件,支持 ItemsSource 绑定并带动画效果。

Converters(常用值转换器)

所有转换器都继承自 ConverterBase<T>,可在 XAML 中以 MarkupExtension 形式直接使用。

  • 布尔相关:BooleanToVisibilityConverterBooleanReverseConverterBooleanReverseToVisibilityConverterBooleanToVisibleHiddenConverterBooleanReverseToVisibleHiddenConverter
  • 枚举:EnumToDescriptionConverter
  • 显示格式:FileSizeConverterNetworkSpeedConverterMultiplyConverterIndexConverter
  • 通用:ObjectToJsonConverterObjectToBooleanConverterObjectToVisibilityConverter

Styles(基础样式资源)

  • Styles/BaseStyle.xaml:基础控件样式集合(Button、TextBox、ListView、Window 等)。
  • Styles/Theme1.xaml:一套可选主题(覆盖部分控件样式)。
  • Styles/Margin*.xaml:常用 Margin 资源集合。

快速开始

1) 在 App.xaml 引入样式资源

<Application.Resources>
 <ResourceDictionary>
 <ResourceDictionary.MergedDictionaries>
 <ResourceDictionary Source="pack://application:,,,/CgdataBase.WPF;component/Styles/BaseStyle.xaml" />
 
 
 </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>
</Application.Resources>

2) 使用转换器(MarkupExtension 方式)

<Window
 xmlns:conv="clr-namespace:CgdataBase.WPF.Converters;assembly=CgdataBase.WPF">
 <Grid>
 <TextBlock Visibility="{Binding IsBusy, Converter={conv:BooleanToVisibilityConverter}}" />
 </Grid>
</Window>

3) 让集合支持后台线程更新

using CgdataBase.WPF.Controllers;

public AsyncObservableCollection<string> Items { get; } = new();

public async Task LoadAsync()
{
 await Task.Run(() =>
 {
 for (var i = 0; i < 100; i++)
 {
 Items.Add($"Item {i}");
 }
 });
}

4) 窗口尺寸/位置自动记忆

using CgdataBase.WPF.Controllers;

public partial class MainWindow : Window
{
 public MainWindow()
 {
 InitializeComponent();
 WindowController.UpdateWindowConfig(this, typeof(MainWindow));
 WindowController.EscToExit(this);
 }
}

5) 在 ItemsControl 中使用 VirtualizingWrapPanel

<ItemsControl xmlns:cg="clr-namespace:CgdataBase;assembly=CgdataBase.WPF"
 ItemsSource="{Binding Items}">
 <ItemsControl.ItemsPanel>
 <ItemsPanelTemplate>
 <cg:VirtualizingWrapPanel ItemWidth="120" ItemHeight="36" />
 </ItemsPanelTemplate>
 </ItemsControl.ItemsPanel>
</ItemsControl>

相关包

  • :通用基础能力(序列化、文件/网络工具、设置存取、扩展方法等)
  • :更偏“应用基建”的 WPF 能力(MVVM 基类、Dialog/事件/更新/Excel 等)
  • 、:更高层的 UI 组件与样式集合

文档

  • API 参考(本仓库已生成静态站点):

License

MIT

Product Versions Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 net6.0-windows7.0 is compatible.  net7.0-windows net7.0-windows was computed.  net8.0-windows net8.0-windows was computed.  net8.0-windows7.0 net8.0-windows7.0 is compatible.  net9.0-windows net9.0-windows was computed.  net10.0-windows net10.0-windows was computed.  net10.0-windows7.0 net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CgdataBase.WPF:

Package Downloads
CgdataBase.WPF.Common

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.9.34 105 6/15/2026
1.9.33 103 6/9/2026
1.9.32 108 6/3/2026
1.9.30 123 5/11/2026
1.9.29 115 5/2/2026
1.9.28 113 4/28/2026
1.9.26 109 4/27/2026
1.9.21 124 4/15/2026
1.9.19 118 4/8/2026
1.9.16 109 4/7/2026
1.9.12 121 4/3/2026
1.9.11 133 3/25/2026
1.9.8 115 3/23/2026
1.9.7 111 3/23/2026
1.9.6 124 3/20/2026
1.9.5 120 3/19/2026
1.9.4 119 3/18/2026
1.9.3 160 1/6/2026
1.9.2 246 12/5/2025
1.9.1 303 11/22/2025
Loading failed