GwhUI 1.0.1.1
dotnet add package GwhUI --version 1.0.1.1
NuGet\Install-Package GwhUI -Version 1.0.1.1
<PackageReference Include="GwhUI" Version="1.0.1.1" />
<PackageVersion Include="GwhUI" Version="1.0.1.1" />
<PackageReference Include="GwhUI" />
paket add GwhUI --version 1.0.1.1
#r "nuget: GwhUI, 1.0.1.1"
#:package GwhUI@1.0.1.1
#addin nuget:?package=GwhUI&version=1.0.1.1
#tool nuget:?package=GwhUI&version=1.0.1.1
GwhUI_Net_40 调用文档
项目概述
GwhUI_Net_40 是一个基于 WPF 的 UI 控件库,提供了一系列现代化、扁平化的控件样式和模板。该项目包含多种常用控件的自定义样式,可以帮助开发者快速构建美观的桌面应用程序。
目录结构
GwhUI_Net_40/
├── Behaviors/ # 行为类
│ └── TextBoxHelper.cs
├── Commons/ # 公共类
│ ├── NotifyObject.cs
│ └── RelayCommand.cs
├── Converters/ # 转换器
│ └── BoolToVisibilityConverter.cs
├── Themes/Styles/ # 样式资源
│ ├── ButtonStyles.xaml
│ ├── IconPaths.xaml
│ ├── ProgressBarStyles.xaml
│ ├── TabControlStyles.xaml
│ ├── TextBlockStyles.xaml
│ ├── TextBoxStyles.xaml
│ └── TreeViewStyles.xaml
控件样式和使用方法
1. 按钮 (Button)
可用样式
FlatButtonPrimary- 主要按钮FlatButtonSuccess- 成功按钮FlatButtonInfo- 信息按钮FlatButtonWarning- 警告按钮FlatButtonDanger- 危险按钮FlatButtonSecondary- 次要按钮FlatButtonIcon- 图标按钮FlatButtonSmall- 小型按钮FlatButtonLarge- 大型按钮
使用示例
<Button Content="主要按钮" Style="{StaticResource FlatButtonPrimary}" />
<Button Content="成功按钮" Style="{StaticResource FlatButtonSuccess}" />
2. 文本框 (TextBox)
可用样式
FlatWatermarkTextBox- 带水印文本框FlatTextBoxOutline- 边框样式文本框FlatTextBoxRounded- 圆角文本框FlatTextBoxSmall- 小尺寸文本框FlatTextBoxLarge- 大尺寸文本框FlatTextBoxSuccess- 成功状态文本框FlatTextBoxWarning- 警告状态文本框FlatTextBoxError- 错误状态文本框FlatTextBoxPrimary- 主要状态文本框FlatTextBoxDisabled- 禁用状态文本框FlatTextBoxReadOnly- 只读状态文本框FlatSearchBox- 搜索框FlatPasswordBox- 密码框FlatTextBoxMultiLine- 多行文本框FlatTextArea- 文本区域FlatTextBoxNoBorder- 无边框文本框FlatTextBoxTransparent- 透明文本框FlatTextBoxDark- 暗色主题文本框FlatNumericBox- 数字文本框
使用示例
<TextBox Text="标准输入框" Style="{StaticResource FlatWatermarkTextBox}" />
<TextBox Text="边框样式" Style="{StaticResource FlatTextBoxOutline}" />
3. 文本块 (TextBlock)
可用样式
FlatTitleLarge- 大型标题FlatTitleMedium- 中型标题FlatTitleSmall- 小型标题FlatBody- 普通正文FlatBodyStrong- 加粗正文FlatLabel- 标签文本FlatTextSuccess- 成功状态文本FlatTextDanger- 危险状态文本FlatLink- 链接文本FlatBadge- 徽章文本FlatBadgeSuccess- 成功徽章FlatCaption- 辅助文本FlatTextMonospace- 等宽字体文本
使用示例
<TextBlock Text="大型标题" Style="{StaticResource FlatTitleLarge}" />
<TextBlock Text="普通正文" Style="{StaticResource FlatBody}" />
4. 进度条 (ProgressBar)
可用样式
FlatProgressBar- 基本进度条FlatProgressBarSuccess- 成功状态进度条FlatProgressBarWarning- 警告状态进度条FlatProgressBarError- 错误状态进度条FlatProgressBarInfo- 信息状态进度条FlatProgressBarDark- 暗色进度条FlatProgressBarThin- 细进度条FlatProgressBarThick- 粗进度条FlatProgressBarRounded- 圆角进度条FlatProgressBarSquare- 方角进度条FlatProgressBarMinimal- 极简进度条FlatProgressBarStriped- 条纹进度条FlatProgressBarIndeterminate- 不确定进度条FlatProgressBarVertical- 垂直进度条FlatProgressBarVerticalSuccess- 垂直成功进度条FlatProgressBarVerticalWarning- 垂直警告进度条
使用示例
<ProgressBar Value="30" Style="{StaticResource FlatProgressBar}" />
<ProgressBar Value="60" Style="{StaticResource FlatProgressBarSuccess}" />
5. TabControl
可用样式
FlatTabControlStyle- 扁平化TabControl样式BorderlessTabControlStyle- 无边框TabControl样式ModernFlatTabControlStyle- 现代化扁平TabControl样式
TabItem样式
CardTabItemStyle- 卡片式TabItemFlatTabItemStyle- 扁平化TabItemIconTabItemStyle- 图标TabItemModernFlatTabItemStyle- 现代化扁平TabItemModernRoundedTabItemStyle- 现代化圆角TabItemModernFilledTabItemStyle- 现代化填充TabItem
使用示例
<TabControl Style="{StaticResource FlatTabControlStyle}">
<TabItem Header="卡片1" Style="{StaticResource CardTabItemStyle}" />
</TabControl>
6. TreeView
可用样式
BaseTreeViewStyle- 基础TreeView样式BaseTreeViewItemStyle- 基础TreeViewItem样式TreeViewItemWithIconsStyle- 带图标TreeViewItem样式CheckBoxTreeViewItemStyle- 带复选框TreeViewItem样式
使用示例
<TreeView ItemContainerStyle="{StaticResource TreeViewItemWithIconsStyle}"
Style="{StaticResource BaseTreeViewStyle}">
<TreeViewItem Header="文件夹" Tag="Folder">
<TreeViewItem Header="文档.docx" Tag="File" />
</TreeViewItem>
</TreeView>
图标资源
在 IconPaths.xaml 中定义了丰富的图标资源,可通过静态资源引用:
<Path Data="{StaticResource IconHome}" />
<Path Data="{StaticResource IconSettings}" />
可用图标包括:Add、Delete、Edit、Search、Save、Refresh、Close、Menu、ArrowRight、ArrowLeft、Check、Download、Upload、Settings、Info、Warning、Error、Home、User、Lock、Mail、Phone、Star、Heart、Camera、Calendar、Cloud、Print、Share、Window、Stopwatch、Folder、Code、Document、Image、Video、Music、Chart、Database等。
在项目中引用GwhUI_Net_40
要在您的项目中使用GwhUI_Net_40,请按以下步骤操作:
- 添加对GwhUI_Net_40项目的引用
- 在App.xaml中合并资源字典:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/ButtonStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/TextBlockStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/TextBoxStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/ProgressBarStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/TabControlStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/TreeViewStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/GwhUI_Net_40;component/Themes/Styles/IconPaths.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
- 在XAML中直接使用样式:
<Button Content="测试按钮" Style="{StaticResource FlatButtonPrimary}" />
行为扩展
TextBoxHelper 提供了附加属性来增强TextBox功能:
TextBoxHelper.Watermark- 设置水印文本
使用示例:
<TextBox commons:TextBoxHelper.Watermark="请输入用户名"
Style="{StaticResource FlatWatermarkTextBox}" />
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.