手把手教你如何用界面组件DevExpress WPF应用一个模板主题
DevExpress WPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpress WPF能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。
DevExpress WPF组件包含超过30+个定制设计的应用主题,开发人员可以再免费的WPF Theme Designer(主题设计器)应用程序中使用这些主题而无需修改或自定义它们。
当开发人员在应用程序中引用DevExpress WPF库时,该应用程序将应用Office2019Colorful,此主题影响所有DevExpress WPF控件和支持的标准WPF控件,开发人员可以重置应用于标准WPF控件的DevExpress主题。

支持的WPF标准控件列表
下面的标准WPF控件支持DevExpress WPF主题。
- System.Windows.Button
- System.Windows.CheckBox
- System.Windows.ComboBox
- System.Windows.ComboBoxItem
- System.Windows.ContextMenu *
- System.Windows.Expander
- System.Windows.GridSplitter
- System.Windows.GroupBox
- System.Windows.Label
- System.Windows.ListBox
- System.Windows.ListBoxItem
- System.Windows.Menu *
- System.Windows.Page
- System.Windows.PasswordBox *
- System.Windows.ProgressBar
- System.Windows.RadioButton
- System.Windows.Controls.Primitives.ScrollBar
- System.Windows.ScrollViewer
- System.Windows.Separator
- System.Windows.Slider
- System.Windows.TabControl
- System.Windows.TabItem
- System.Windows.TextBox
- System.Windows.ToolTip
- System.Windows.TreeView
- System.Windows.TreeViewItem
*这些控件仅在Office2016SE、VS2017、Office2019和VS2019主题中支持。
应用一个DevExpress主题
要应用主题,必须在项目中引用主题程序集或主题NuGet包。
方法1
打开Window或User Control的快速操作或智能标记,展开ApplicationTheme下拉列表,并选择一个主题,该列表仅显示项目中引用的主题。

生成的App.config文件如下所示:
- .NET
App.config
... <configuration> <configSections> <section name="DXThemeManager" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </configSections> <DXThemeManager> <setting name="ApplicationThemeName" serializeAs="String"> <value>Office2019Colorful</value> </setting> </DXThemeManager> </configuration> ...
- .NET Framework
App.config
<configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="DXThemeManager" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> </configSections> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> </startup> <userSettings> <DXThemeManager> <setting name="ApplicationThemeName" serializeAs="String"> <value>Office2019Colorful</value> </setting> </DXThemeManager> </userSettings> </configuration>
方法2
这种方法会覆盖使用方法1对App.config文件所做的更改。
1. 引用DevExpress.Data.Desktop.v22.1程序集。
2. 在应用程序启动时将ApplicationThemeHelper.ApplicationThemeName属性设置为一个主题名称。
C#
public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { ApplicationThemeHelper.ApplicationThemeName = Theme.MetropolisLightName; base.OnStartup(e); } }
VB.NET
Class Application Protected Overrides Sub OnStartup(e As StartupEventArgs) ApplicationThemeHelper.ApplicationThemeName = Theme.MetropolisLightName MyBase.OnStartup(e) End Sub End Class
提示:可以将 Ribbon Gallery 主题选择器添加到应用程序中。
应用一个DevExpress主题到容器
指定附加的ThemeManager.ThemeName属性,开发人员可以将该属性应用到DevExpress WPF控件和受支持的WPF标准控件。下面的代码示例将Office2016SEWhite主题应用到ThemedWindow,将office20119black主题应用到GridControl:
XAML
<ThemedWindow ... xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" dx:ThemeManager.ThemeName="Office2016SEWhite"> <dxg:GridControl dx:ThemeManager.ThemeName="Office2019Black"> ... </dxg:GridControl> </ThemedWindow>
DevExpress技术交流群6:600715373 欢迎一起进群讨论
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
2021-11-22 New!DevExpress WPF v21.2最新版本系统环境配置要求
2021-11-22 VS插件CodeRush 全新发布v21.2.4——支持Visual Studio 2022
2019-11-22 .NET Core 3时代DevExpress Winforms v19.2增强Scheduler控件
2018-11-22 DevExpress WinForms v18.2新版亮点(三)
2017-11-22 DevExpress v17.2新版亮点—WinForms篇(一)