CgdataBase.WPF.Metro
1.9.21
dotnet add package CgdataBase.WPF.Metro --version 1.9.21
NuGet\Install-Package CgdataBase.WPF.Metro -Version 1.9.21
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.Metro" Version="1.9.21" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CgdataBase.WPF.Metro" Version="1.9.21" />
<PackageReference Include="CgdataBase.WPF.Metro" />
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.Metro --version 1.9.21
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CgdataBase.WPF.Metro, 1.9.21"
#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.Metro@1.9.21
#: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.Metro&version=1.9.21
#tool nuget:?package=CgdataBase.WPF.Metro&version=1.9.21
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CgdataBase.WPF.Metro
CgdataBase.WPF.Metro 是基于 MahApps.Metro 的 WPF UI 扩展库,建立在 CgdataBase.WPF.Common 之上,提供一套可直接复用的 Metro 风格基础样式资源,以及常用对话框/窗口(消息框、输入框、字体选择、设置/关于等)。
安装
Install-Package CgdataBase.WPF.Metro
dotnet add package CgdataBase.WPF.Metro
目标框架
- net8.0-windows
- net10.0-windows
依赖项
- CgdataBase.WPF.Common
- MahApps.Metro
- ReactiveUI
- Fody / PropertyChanged.Fody
包含内容
Styles(基础样式资源)
位于 Styles/,主要用于统一控件间距、对话框窗口行为与常用控件样式。
BaseStyle.xaml:聚合基础控件样式(Button / TextBox / DataGrid / Window 等)Base/Window.xaml:提供DialogWindowStyle/DialogWindowStyle2,用于统一 MetroWindow 对话框行为(如隐藏任务栏图标、禁用调整大小等)Margin1.xaml~Margin6.xaml:提供ControlMargin资源(1~6),用于统一控件间距Fonts.xaml:覆盖 MahApps 默认字体/字号/大小写规则(可按需引入)
Views(可直接复用的窗口/对话框)
位于 Views/,均基于 MahApps.Metro.Controls.MetroWindow。
MessageBox:与 WPFMessageBox类似的消息框,提供Show(...)静态方法(支持OK/OKCancel/YesNo/YesNoCancel),并确保在 UI 线程显示InputBox:带提示文本的输入框(必填校验,空值会提示并聚焦输入框)InputBox2:简化输入框(适合更大文本输入,默认尺寸可通过IocManage配置)WinSelectFont:字体选择窗口(支持只显示中文字体、关键字过滤、双击确认)WinSettingsBase+UcSettingsBase:通用“设置”窗口与内容控件,包含字体/数据库/文本字体等常用设置项(配合WinSettingsBaseViewModel使用)WinAbout:通用“关于”窗口,显示应用名/版本/ReleaseNote,并可选启用“检查更新/版本信息”
ViewModels(配套 ViewModel)
位于 ViewModels/。
WinAboutViewModel:加载应用信息与ReleaseNote.txt,可选触发版本检查逻辑WinSettingsBaseViewModel:设置窗口的默认实现,提供校验、字体选择、数据库连接串生成等逻辑;支持SettingsMode控制页面显示项
快速开始
1) 引入资源字典(App.xaml)
需要先引入 MahApps 的基础资源,再引入本库的 Margin/BaseStyle(示例可参考 CgdataBaseDemo/App.xaml)。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Emerald.xaml" />
<ResourceDictionary Source="pack://application:,,,/CgdataBase.WPF.Metro;Component/Styles/Margin2.xaml" />
<ResourceDictionary Source="pack://application:,,,/CgdataBase.WPF.Metro;Component/Styles/BaseStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
2) 使用消息框与输入框
using System.Windows;
using CgdataBase.Views;
var result = CgdataBase.Views.MessageBox.Show(this, "确定要删除吗?", "提示", MessageBoxButton.YesNo);
var name = InputBox.Show(this, "请输入名称:", value: "", title: "输入");
if (!string.IsNullOrWhiteSpace(name))
{
// use name
}
3) 使用设置窗口(WinSettingsBase + WinSettingsBaseViewModel)
using CgdataBase;
using CgdataBase.ViewModels;
using CgdataBase.Views;
IAppSettingsBase settings = ...;
var win = new WinSettingsBase { Owner = this };
win.DataContext = new WinSettingsBaseViewModel(settings, SettingsMode.字体_数据库);
var ok = win.ShowDialog() == true;
4) 使用关于窗口(WinAbout + WinAboutViewModel)
using CgdataBase;
using CgdataBase.ViewModels;
using CgdataBase.Views;
IAppSettingsBase settings = ...;
var win = new WinAbout { Owner = this };
var vm = new WinAboutViewModel();
vm.LoadInfo(settings, appName: "MyApp", checkVersion: true);
win.DataContext = vm;
win.ShowDialog();
当应用输出目录存在 ReleaseNote.txt 时,WinAboutViewModel 会读取并显示其内容。
| Product | Versions 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.
-
net10.0-windows7.0
- CgdataBase.WPF.Common (>= 1.9.21)
- MahApps.Metro (>= 2.4.11)
- ReactiveUI (>= 23.1.8)
-
net8.0-windows7.0
- CgdataBase.WPF.Common (>= 1.9.21)
- MahApps.Metro (>= 2.4.11)
- ReactiveUI (>= 23.1.8)
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 |
|---|---|---|
| 1.9.21 | 84 | 4/15/2026 |
| 1.9.19 | 88 | 4/8/2026 |
| 1.9.16 | 87 | 4/7/2026 |
| 1.9.12 | 93 | 4/3/2026 |
| 1.9.11 | 102 | 3/25/2026 |
| 1.9.8.2 | 89 | 3/23/2026 |
| 1.9.7 | 88 | 3/23/2026 |
| 1.9.6 | 87 | 3/20/2026 |
| 1.9.5 | 92 | 3/19/2026 |
| 1.9.4 | 91 | 3/18/2026 |
| 1.9.3.4 | 109 | 2/10/2026 |
| 1.9.3.2 | 95 | 2/10/2026 |
| 1.9.3 | 107 | 1/6/2026 |
| 1.9.2.3 | 193 | 12/25/2025 |
| 1.9.2.2 | 136 | 12/13/2025 |
| 1.9.2.1 | 194 | 12/5/2025 |
| 1.9.1.3 | 198 | 11/25/2025 |
| 1.9.1 | 287 | 11/22/2025 |
| 1.9.0 | 331 | 11/21/2025 |
| 1.8.3.1 | 417 | 11/21/2025 |
Loading failed