TianWeiToolsPro.UI 3.2.2

dotnet add package TianWeiToolsPro.UI --version 3.2.2
                    
NuGet\Install-Package TianWeiToolsPro.UI -Version 3.2.2
                    
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="TianWeiToolsPro.UI" Version="3.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TianWeiToolsPro.UI" Version="3.2.2" />
                    
Directory.Packages.props
<PackageReference Include="TianWeiToolsPro.UI" />
                    
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 TianWeiToolsPro.UI --version 3.2.2
                    
#r "nuget: TianWeiToolsPro.UI, 3.2.2"
                    
#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 TianWeiToolsPro.UI@3.2.2
                    
#: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=TianWeiToolsPro.UI&version=3.2.2
                    
Install as a Cake Addin
#tool nuget:?package=TianWeiToolsPro.UI&version=3.2.2
                    
Install as a Cake Tool

TianWeiToolsPro.UI

TianWeiToolsPro.UI 是面向 Windows WPF 应用的控件与主题资源库,提供导航、表单、对话框、状态提示等常用控件,以及亮色、暗色和强调色资源。可用于工业上位机等桌面界面;图像显示与 ROI 绘制由独立的 TianWeiToolsPro.UI.Drawing 包提供。

目标框架

当前包支持以下目标框架(以项目文件为准):

  • .NET Framework 4.7.2
  • .NET Framework 4.8
  • .NET 6 (Windows)
  • .NET 8 (Windows)
  • .NET 10 (Windows)

本库是 WPF 控件库,仅适用于 Windows 桌面应用,并依赖 TianWeiToolsPro.Common。

平台支持

本库仅支持 Windows x64(64 位)进程,不再兼容 x86(32 位)进程。

主要内容

场景 控件与资源示例
窗口与导航 FluentWindow、NavigationView、NavigationViewItem
常规输入 Button、TextBox、ComboBox、NumberBox、CheckBox、ColorPicker
参数表单 GroupBox、ParamsTextBox、ParamsComboBox、FilletHeaderControl
对话与反馈 ContentDialog、ContentDialogHost、SnackbarPresenter、InfoBar
其他界面元素 TabItemEx、DynamicScrollViewer、DynamicScrollBar、ProgressRing

ParamsTextBox 和 ParamsComboBox 将参数名称、输入值与可选单位排在同一行;Unit 为空或仅有空白时,单位区域会折叠。标签、单位的字体、颜色及尺寸均可分别设置。

快速开始

从项目配置的 NuGet 源安装 TianWeiToolsPro.UI,或在解决方案中引用 TianWeiToolsPro.UI.csproj。然后在 WPF 应用的 App.xaml 合并主题与控件资源。以下示例使用亮色主题;需要暗色主题时,将 Light.xaml 换为 Dark.xaml。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/TianWeiToolsPro.UI;component/Resources/Theme/Light.xaml" />
            <ResourceDictionary Source="pack://application:,,,/TianWeiToolsPro.UI;component/Resources/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/TianWeiToolsPro.UI;component/Themes/Generic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

在窗口或页面根节点声明命名空间:

xmlns:ui="http://schemas.tianwei.tools/ui/xaml"

参数表单示例:

<ui:GroupBox Header="运动参数">
    <StackPanel>
        <ui:ParamsTextBox Label="速度"
                          Text="{Binding SpeedText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          Unit="mm/s" />
        <ui:ParamsComboBox Label="工作台"
                           ItemsSource="{Binding Worktables}"
                           SelectedItem="{Binding SelectedWorktable, Mode=TwoWay}" />
    </StackPanel>
</ui:GroupBox>

主题资源

FluentWindow 默认使用四角圆角,可通过 WindowCornerPreference="Round"、"RoundSmall" 或 "DoNotRound" 选择标准圆角、小圆角或直角。最大化时使用直角,恢复后重新应用圆角;运行时修改该属性也会立即更新。Windows 11 使用系统原生圆角,旧系统通过零玻璃边框的 WindowChrome 回退实现(标准半径 8、小圆角半径 4 个 WPF 单位)。不需要设置 AllowsTransparency。

  • Resources/Theme/Light.xaml 和 Dark.xaml 提供亮色、暗色主题的基础颜色与画刷。
  • Resources/Theme/Accent.xaml 提供强调色及透明度变体;Resources/Theme/Brushes.xaml、Palette.xaml 等提供共享资源。
  • Resources/Variables.xaml 集中存放布局与控件尺寸变量;Themes/Generic.xaml 是默认样式入口,Controls/ControlsStyles.xaml 合并扩展控件样式。
  • 资源 Key 使用 TianWeiToolsPro.UI.Colors.* 和 TianWeiToolsPro.UI.Brushes.* 命名。应用界面引用主题画刷时,建议使用 DynamicResource,以便运行时切换主题。

运行时可通过 IThemeService / ThemeService 切换亮暗主题、使用预设强调色,或传入 Color 自定义强调色。预设色包含 DodgerBlue;Apply(bool useDarkTheme, string? accentName) 应在应用资源初始化后调用。

项目说明

  • 控件及其默认模板以当前源码和资源字典为准;本 README 仅列出常用入口。
  • TianWeiToolsPro.UI.Drawing 是独立项目,不包含在本包的控件清单中。
  • NuGet 包使用本文件作为包说明页;项目文件中的 PackageReadmeFile 与打包资源配置会将 ReadMe.md 放入包根目录。
Product 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 is compatible.  net481 was computed. 
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 TianWeiToolsPro.UI:

Package Downloads
TianWeiToolsPro

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.2 39 10/21/2026
3.2.0 100 9/29/2026