没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:龚雪|2021-08-04 10:23:19.930|阅读 219 次
概述:本教程将为大家介绍如何使用主题调色板,来优化WPF应用程序的主题,欢迎下载最新版体验~
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
DevExpress WPF控件调色板允许您将颜色(例如公司颜色)集成到WPF应用程序中并自定义主题中使用的颜色,在此实例中您可以创建自定义调色板或使用预定义调色板。
Palette是命名颜色的列表,每种颜色都有一个ColorName值和一个Color值,您可以使用ColorName将颜色分配给任意数量的UI元素:
注意:您可以使用 WPF 主题设计器来编辑调色板颜色或将其绑定到 UI 元素。
以下 DevExpress WPF 主题包含的调色板:
包括以下预定义的调色板:
注意:当您切换主题时,应用程序不会卸载加载的主题程序集。
1. 在您的项目中引用 NuGet 包。
2. 调用 方法来启用预定义的调色板。
3. 将 属性设置为所需的预定义调色板名称和基本主题名称组合。
C#
Theme.RegisterPredefinedPaletteThemes(); ApplicationThemeHelper.ApplicationThemeName = PredefinedThemePalettes.RedWine.Name + Theme.Office2019White.Name;
VB.NET
Theme.RegisterPredefinedPaletteThemes() ApplicationThemeHelper.ApplicationThemeName = PredefinedThemePalettes.RedWine.Name + Theme.Office2019White.Name
TIP:您可以使用 属性来缓存当前调色板主题程序集,缓存减少了未来应用程序运行的加载时间。
上面的代码示例为当前主题启用了所有可用的调色板,要启用和应用单个调色板:
1. 在您的项目中引用 NuGet 包。
2. 将调色板和基本主题传递给方法以创建新主题。
3. 将主题传递给 方法。
4. 将 属性设置为主题名称。
C#
var palettetheme = Theme.CreateTheme(PredefinedThemePalettes.RedWine, Theme.Office2019White); Theme.RegisterTheme(palettetheme); ApplicationThemeHelper.ApplicationThemeName = palettetheme.Name;
VB.NET
Dim palettetheme = Theme.CreateTheme(PredefinedThemePalettes.RedWine, Theme.Office2019White) Theme.RegisterTheme(palettetheme) ApplicationThemeHelper.ApplicationThemeName = palettetheme.Name
您可以在中显示预定义的调色板,来允许用户选择调色板并将其应用于当前主题:
1. 参考 DevExpress.Mvvm.v21.1.dll 程序集。
2. 在应用程序启动时调用 方法以启用这些调色板:
C#
public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { Theme.RegisterPredefinedPaletteThemes(); base.OnStartup(e); } }
VB.NET
Public Partial Class App Inherits Application Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs) Theme.RegisterPredefinedPaletteThemes() MyBase.OnStartup(e) End Sub End Class
3. 将 RibbonGalleryItemThemePaletteSelectorBehavior 附加到 RibbonGalleryBarItem:
XAML
<dxr:RibbonGalleryBarItem ... > <dxmvvm:Interaction.Behaviors> <dxr:RibbonGalleryItemThemePaletteSelectorBehavior /> </dxmvvm:Interaction.Behaviors> </dxr:RibbonGalleryBarItem>
您可以使用带有Windows 10 Light主题的Win10 Palette预定义调色板来获取 Windows 10 强调色,并在您的应用程序中使用该颜色。
以下代码示例使用 Windows 10 强调色创建新的 Win10Light 主题,并在应用程序启动时应用该主题:
C#
protected override void OnStartup(StartupEventArgs e) { var accentpalette = new Win10Palette(); var customtheme = Theme.CreateTheme(accentpalette, Theme.Win10Light); Theme.RegisterTheme(customtheme); ApplicationThemeHelper.ApplicationThemeName = customtheme.Name; base.OnStartup(e); }
VB.NET
Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs) Dim accentpalette = New Win10Palette() Dim customtheme = Theme.CreateTheme(accentpalette, Theme.Win10Light) Theme.RegisterTheme(customtheme) ApplicationThemeHelper.ApplicationThemeName = customtheme.Name MyBase.OnStartup(e) End Sub
注意:Win10 Palette仅适用于 Windows 10 操作系统版本,Win10 Palette 中没有找到Windows 强调色,应用程序强调色设置为#FF0078D7。
在代码中编辑调色板
注意:当您切换主题时,应用程序不会卸载加载的主题程序集。
将自定义调色板应用于应用程序:
1. 在您的项目中引用 NuGet 包。
2. 创建一个新的 实例:
C#
var custompalette = new ThemePalette("CustomPalette");
VB.NET
Dim custompalette = New ThemePalette("CustomPalette")
...或基于预定义的调色板创建一个新的 ThemePalette 实例,在这种情况下,新调色板继承了预定义调色板的颜色:
C#
var custompalette = new ThemePalette("CustomPalette", PredefinedThemePalettes.RedWine);
VB.NET
Dim custompalette = new ThemePalette("CustomPalette", PredefinedThemePalettes.RedWine)
3. 使用方法指定新颜色:
C#
custompalette.SetColor("Foreground", (Color)ColorConverter.ConvertFromString("#FFFF7200")); custompalette.SetColor("Backstage.Focused", Colors.White);
VB.NET
custompalette.SetColor("Foreground", ColorConverter.ConvertFromString("#FF015C9F")) custompalette.SetColor("Foreground", Colors.White)
将调色板和具有调色板支持的主题传递给 方法来创建新主题:
C#
var customtheme = Theme.CreateTheme(custompalette, Theme.Office2016ColorfulSE);
VB.NET
Dim customtheme = Theme.CreateTheme(custompalette, Theme.Office2016ColorfulSE)
将主题传递给方法并将设置为主题的名称,来将主题应用于应用程序:
C#
var custompalette = new ThemePalette("CustomPalette"); custompalette.SetColor("Foreground", (Color)ColorConverter.ConvertFromString("#FFFF7200")); custompalette.SetColor("Backstage.Focused", Colors.White); var customtheme = Theme.CreateTheme(custompalette, Theme.Office2016ColorfulSE); Theme.RegisterTheme(customtheme); ApplicationThemeHelper.ApplicationThemeName = customtheme.Name;
VB.NET
Dim custompalette = New ThemePalette("CustomPalette") custompalette.SetColor("Foreground", ColorConverter.ConvertFromString("#FF015C9F")) custompalette.SetColor("Backstage.Focused", Colors.White) Dim customtheme = Theme.CreateTheme(custompalette, Theme.Office2016ColorfulSE) Theme.RegisterTheme(customtheme) ApplicationThemeHelper.ApplicationThemeName = customtheme.Name
#在使用单个文件部署的 .NET 5 应用程序中在运行时更改主题
DevExpress WPF 主题程序集必须提取到磁盘,发布 .NET 5 应用程序(PublishSingleFile 为 true)时,将项目文件中的 IncludeAllContentForSelfExtract 选项设置为 true,这将允许用户在运行时应用调色板。
XAML
<PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> <UseWPF>true</UseWPF> <Nullable>enable</Nullable> <PublishSingleFile>true</PublishSingleFile> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> </PropertyGroup>
DevExpress WPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpress WPF能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。 无论是Office办公软件的衍伸产品,还是以数据为中心的商业智能产品,都能通过DevExpress WPF控件来实现。
DevExpress技术交流群4:715863792 欢迎一起进群讨论
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
文章转载自:慧都网从版本2025.2.2开始, Stimulsoft 产品中引入了一个新的关系参数JoinType 。它定义了两个数据源之间的连接类型。在本文中,我们将深入探讨如何使用此参数。
本文将详细介绍如何使用 C# 和 Spire.XLS for .NET 库将 Excel XLS 或 XLSX 文件转换为 Markdown 格式。
Webix 是一套完整的前端开发框架,它允许开发者利用 JavaScript、CSS 和 HTML5 技术,快速构建出富交互性的 Web 应用程序。该框架提供了超过 100 个预制且可高度定制的组件,涵盖了数据表格、图表、表单、布局等各类常见的用户界面元素。无论是经验丰富的专业开发者,还是初涉 Web 开发领域的新手,都能从 Webix 的易用性和强大功能中受益。
CAD VCL Multiplatform是一个高质量的多功能源代码库,可用于 Delphi 和 C++Builder 应用程序。支持 2D 和 3D CAD 格式,包括DWG、DXF、 HPGL PLT、HGL、STEP、IGES、STL、ACIS SAT、BREP、CGM、SVG等。该产品不需要安装 AutoCAD® 或其他附加应用程序。
高效MVVM开发模式,WPF界面解决方案首选工具,帮助企业实现酷炫动效界面。
DevExpress Universal Subscription优秀的界面控件开发包,帮助企业构建卓越应用!
DevExpress DXperience Subscription高性价比的企业级.NET用户界面套包,助力企业创建卓越应用!
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢