CgdataBase.WPF.Common 1.9.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package CgdataBase.WPF.Common --version 1.9.6
                    
NuGet\Install-Package CgdataBase.WPF.Common -Version 1.9.6
                    
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="1.9.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CgdataBase.WPF.Common" Version="1.9.6" />
                    
Directory.Packages.props
<PackageReference Include="CgdataBase.WPF.Common" />
                    
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.Common --version 1.9.6
                    
#r "nuget: CgdataBase.WPF.Common, 1.9.6"
                    
#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@1.9.6
                    
#: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=1.9.6
                    
Install as a Cake Addin
#tool nuget:?package=CgdataBase.WPF.Common&version=1.9.6
                    
Install as a Cake Tool

CgdataBase.WPF.Common

概述

CgdataBase.WPF.Common 是基于 CgdataBase.WPF 的 WPF 通用基础库,主要提供一组可复用的 MVVM 绑定行为、应用基础设施与常用控制器/工具类,帮助统一 WPF 项目的通用能力实现(通知、单例、Dock、UI 状态持久化、Excel、校验、版本检查等)。

目标框架

  • net8.0-windows
  • net10.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 / ListBoxSelectedItems 提供简单附加属性封装
  • 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:通知/Toast
  • NPOI:Excel 读写
  • Prism.Unity:MVVM/依赖注入/事件聚合
  • ReactiveUI:响应式编程支持

备注

  • 本库依赖并复用 CgdataBase.WPF 中的基础能力(例如 UISettingsJsonEngineBindableBase 等)。
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  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 (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
1.9.21 86 4/15/2026
1.9.19 87 4/8/2026
1.9.16 86 4/7/2026
1.9.12 91 4/3/2026
1.9.11 100 3/25/2026
1.9.8 91 3/23/2026
1.9.7 87 3/23/2026
1.9.6 91 3/20/2026
1.9.5 91 3/19/2026
1.9.4 88 3/18/2026
1.9.3 133 1/6/2026
1.9.2.3 208 12/25/2025
1.9.2.2 144 12/13/2025
1.9.2 189 12/5/2025
1.9.1.3 201 11/25/2025
1.9.1 274 11/22/2025
1.9.0 341 11/21/2025
1.8.3 444 11/20/2025
1.8.2.6 412 11/19/2025
1.8.2.1 424 11/18/2025
Loading failed