CgdataBase.WPF.Common
12.1.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package CgdataBase.WPF.Common --version 12.1.0
NuGet\Install-Package CgdataBase.WPF.Common -Version 12.1.0
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.Common" Version="12.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CgdataBase.WPF.Common" Version="12.1.0" />
<PackageReference Include="CgdataBase.WPF.Common" />
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.Common --version 12.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CgdataBase.WPF.Common, 12.1.0"
#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.Common@12.1.0
#: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.Common&version=12.1.0
#tool nuget:?package=CgdataBase.WPF.Common&version=12.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CgdataBase.WPF.Common
概述
CgdataBase.WPF.Common 是基于 CgdataBase.WPF 的 WPF 通用基础库,主要提供一组可复用的 MVVM 绑定行为、应用基础设施与常用控制器/工具类,帮助统一 WPF 项目的通用能力实现(通知、单例、Dock、UI 状态持久化、Excel、校验、版本检查等)。
目标框架
net8.0-windowsnet10.0-windows
目录结构
Behaviors/:WPF 行为(Behavior)与附加属性(Attached Property),用于提升 XAML 可绑定性与交互一致性Events/:基于 Prism 的事件定义(PubSubEvent)Helpers/:应用基础设施、控制器与通用工具类ViewModelBase.cs:通用 ViewModel 基类
主要能力
1) MVVM 绑定行为与附加属性(Behaviors)
AvalonEditBehaviour:为 AvalonEdit 提供CodeText双向绑定能力(支持 MVVM 绑定编辑器文本)PasswordBoxBehaviour:为PasswordBox提供Password双向绑定能力(支持 MVVM 绑定密码)DataGridSelectedItemsBehavior/ListBoxSelectedItemsBehavior:为多选控件提供SelectedItems绑定能力BindingSelectItemsAttach:为DataGrid/ListBox的SelectedItems提供简单附加属性封装DialogCloser:通过附加属性设置Window.DialogResult,便于 MVVM 关闭对话框ScrollIntoViewBehavior:附加属性触发ScrollIntoView,用于列表/表格自动滚动定位TreeViewHelper:为TreeView提供SelectedItem可绑定能力
2) 应用基础设施(Helpers)
ApplicationBase- 全局异常捕获(UI 线程、Task、AppDomain)并统一记录日志/弹出提示
- 通知封装(基于
Notification.Wpf) - 单例启动支持(互斥锁 + 命名管道唤醒)
- 常用窗口与应用信息获取(活跃窗口、程序集名、应用数据目录等)
AppSettingsBase:基础配置类(XML 持久化),包含常用 UI/字体、数据库、更新服务等默认配置项IocManage:对 Prism 容器、事件聚合器与全局配置的统一访问入口
3) UI 状态持久化(Helpers)
DataGridController:保存/恢复DataGrid列宽、可见性等显示信息GridController:保存/恢复Grid的行高/列宽(基于 JSON 序列化)ColumnDisplayInfo:列显示信息模型(同时支持DataGridLength/GridLength)
4) Dock/文档管理(Helpers)
DockController:基于 AvalonDock 的文档页管理封装(打开/激活/关闭文档、更新标题、获取活动内容等)
5) 数据导入导出(Helpers)
ExcelController:基于 NPOI 的 Excel 读写辅助(打开/创建工作簿、导入为DataTable等)
6) 版本检查与更新探测(Helpers)
UpdateHelper:基于 NetMQ 的版本请求(同步/异步)VersionController:版本检查与提示封装(可主动提示最新版本信息)
7) 数据校验与通用工具(Helpers)
ValidationController:轻量校验器,支持链式条件校验、错误聚合、失败回调策略TextCodeGuessHelper:文本编码识别与读取工具(支持 UTF-8/Unicode/GBK 等;可注册更多编码)FontController:系统字体枚举与中文字体筛选PipeController:命名管道服务端/客户端封装(用于单例唤醒、消息通知)ElementHelper:少量历史兼容方法与通用能力(部分成员已标记过时)
8) Prism 事件定义(Events)
ShowMainWindowEvent/HideMainWindowEvent:主窗口显示/隐藏事件ApplicationExitEvent:应用退出事件ShowWindowEvent/HideWindowEvent:旧事件(已标记过时,保留用于兼容)
第三方依赖
本库通过 NuGet 引用以下组件(以项目文件为准):
AvalonEdit:代码编辑器控件Extended.Wpf.Toolkit:扩展控件库(包含 AvalonDock)gong-wpf-dragdrop:拖拽支持MahApps.Metro.IconPacks:图标资源包Mapster:对象映射Microsoft.Xaml.Behaviors.Wpf:Behavior 基础设施NetMQ:消息通信(用于版本探测)Newtonsoft.Json:JSON 序列化/反序列化NLog:日志Notification.Wpf:通知/ToastNPOI:Excel 读写Prism.Unity:MVVM/依赖注入/事件聚合ReactiveUI:响应式编程支持
备注
- 本库依赖并复用
CgdataBase.WPF中的基础能力(例如UISettings、JsonEngine、BindableBase等)。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. net10.0-windows7.0 is compatible. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.2
- AvalonEdit (>= 6.3.1.120)
- CgdataBase.WPF (>= 12.1.0)
- gong-wpf-dragdrop (>= 4.0.0)
- MahApps.Metro.IconPacks.Material (>= 6.2.1)
- Mapster (>= 10.0.11)
- NetMQ (>= 4.0.1.13)
- NLog (>= 5.2.8)
- Notification.Wpf (>= 8.0.0)
- Prism.DryIoc (>= 8.1.97)
- ReactiveUI (>= 19.5.41)
-
net10.0-windows7.0
- AvalonEdit (>= 6.3.1.120)
- CgdataBase.WPF (>= 12.1.0)
- gong-wpf-dragdrop (>= 4.0.0)
- MahApps.Metro.IconPacks.Material (>= 6.2.1)
- Mapster (>= 10.0.11)
- NetMQ (>= 4.0.1.13)
- NLog (>= 5.2.8)
- Notification.Wpf (>= 8.0.0)
- Prism.DryIoc (>= 8.1.97)
- ReactiveUI (>= 19.5.41)
-
net6.0-windows7.0
- AvalonEdit (>= 6.3.1.120)
- CgdataBase.WPF (>= 12.1.0)
- gong-wpf-dragdrop (>= 4.0.0)
- MahApps.Metro.IconPacks.Material (>= 6.2.1)
- Mapster (>= 10.0.11)
- Microsoft.Xaml.Behaviors.Wpf (>= 1.1.135)
- NetMQ (>= 4.0.1.13)
- NLog (>= 5.2.8)
- Notification.Wpf (>= 8.0.0)
- Prism.DryIoc (>= 8.1.97)
- ReactiveUI (>= 19.5.41)
-
net8.0-windows7.0
- AvalonEdit (>= 6.3.1.120)
- CgdataBase.WPF (>= 12.1.0)
- gong-wpf-dragdrop (>= 4.0.0)
- MahApps.Metro.IconPacks.Material (>= 6.2.1)
- Mapster (>= 10.0.11)
- NetMQ (>= 4.0.1.13)
- NLog (>= 5.2.8)
- Notification.Wpf (>= 8.0.0)
- Prism.DryIoc (>= 8.1.97)
- ReactiveUI (>= 19.5.41)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CgdataBase.WPF.Common:
| Package | Downloads |
|---|---|
|
CgdataBase.WPF.Plus
Package Description |
|
|
CgdataBase.WPF.Metro
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.1.0 | 35 | 8/19/2026 |
| 12.0.13 | 115 | 7/31/2026 |
| 12.0.12 | 97 | 7/29/2026 |
| 12.0.11 | 102 | 7/29/2026 |
| 12.0.10 | 104 | 7/26/2026 |
| 12.0.9.1 | 106 | 7/23/2026 |
| 12.0.9 | 109 | 7/22/2026 |
| 12.0.4 | 145 | 7/3/2026 |
| 12.0.1 | 114 | 6/30/2026 |
| 12.0.0 | 114 | 6/24/2026 |
| 1.9.34 | 120 | 6/15/2026 |
| 1.9.33 | 118 | 6/9/2026 |
| 1.9.32 | 114 | 6/3/2026 |
| 1.9.30 | 117 | 5/11/2026 |
| 1.9.29 | 114 | 5/2/2026 |
| 1.9.28 | 117 | 4/28/2026 |
| 1.9.26 | 117 | 4/27/2026 |
| 1.9.21 | 120 | 4/15/2026 |
| 1.9.19 | 121 | 4/8/2026 |
| 1.9.16 | 116 | 4/7/2026 |
Loading failed