手把手教你如何用界面组件DevExpress WPF应用一个模板主题

📅 2026/8/22 16:16:06
手把手教你如何用界面组件DevExpress WPF应用一个模板主题
DevExpress WPF拥有120个控件和库将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpress WPF能创建有着强大互动功能的XAML基础应用程序这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。DevExpress新旧版本帮助文档下载可进QQ qun获取169725316DevExpress WPF组件包含超过30个定制设计的应用主题开发人员可以再免费的WPF Theme Designer主题设计器应用程序中使用这些主题而无需修改或自定义它们。当开发人员在应用程序中引用DevExpress WPF库时该应用程序将应用Office2019Colorful此主题影响所有DevExpress WPF控件和支持的标准WPF控件开发人员可以重置应用于标准WPF控件的DevExpress主题。支持的WPF标准控件列表下面的标准WPF控件支持​​​​​​​DevExpress WPF主题。System.Windows.ButtonSystem.Windows.CheckBoxSystem.Windows.ComboBoxSystem.Windows.ComboBoxItemSystem.Windows.ContextMenu *System.Windows.ExpanderSystem.Windows.GridSplitterSystem.Windows.GroupBoxSystem.Windows.LabelSystem.Windows.ListBoxSystem.Windows.ListBoxItemSystem.Windows.Menu *System.Windows.PageSystem.Windows.PasswordBox *System.Windows.ProgressBarSystem.Windows.RadioButtonSystem.Windows.Controls.Primitives.ScrollBarSystem.Windows.ScrollViewerSystem.Windows.SeparatorSystem.Windows.SliderSystem.Windows.TabControlSystem.Windows.TabItemSystem.Windows.TextBoxSystem.Windows.ToolTipSystem.Windows.TreeViewSystem.Windows.TreeViewItem*这些控件仅在Office2016SE、VS2017、Office2019和VS2019主题中支持。应用一个DevExpress主题要应用主题必须在项目中引用主题程序集或主题NuGet包。方法1打开Window或User Control的快速操作或智能标记展开ApplicationTheme下拉列表并选择一个主题该列表仅显示项目中引用的主题。生成的App.config文件如下所示.NETApp.config... configuration configSections section nameDXThemeManager typeSystem.Configuration.ClientSettingsSection, System, Version4.0.0.0, Cultureneutral, PublicKeyTokenb77a5c561934e089 allowExeDefinitionMachineToLocalUser requirePermissionfalse / /configSections DXThemeManager setting nameApplicationThemeName serializeAsString valueOffice2019Colorful/value /setting /DXThemeManager /configuration ....NET FrameworkApp.configconfiguration configSections sectionGroup nameuserSettings typeSystem.Configuration.UserSettingsGroup, System, Version4.0.0.0, Cultureneutral, PublicKeyTokenb77a5c561934e089 section nameDXThemeManager typeSystem.Configuration.ClientSettingsSection, System, Version4.0.0.0, Cultureneutral, PublicKeyTokenb77a5c561934e089 allowExeDefinitionMachineToLocalUser requirePermissionfalse / /sectionGroup /configSections startup supportedRuntime versionv4.0 sku.NETFramework,Versionv4.7.2 / /startup userSettings DXThemeManager setting nameApplicationThemeName serializeAsString valueOffice2019Colorful/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.NETClass 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主题应用到GridControlXAMLThemedWindow ... xmlns:dxhttp://schemas.devexpress.com/winfx/2008/xaml/core xmlns:dxghttp://schemas.devexpress.com/winfx/2008/xaml/grid dx:ThemeManager.ThemeNameOffice2016SEWhite dxg:GridControl dx:ThemeManager.ThemeNameOffice2019Black ... /dxg:GridControl /ThemedWindow