简体   繁体   English

如何以编程方式获取 UWP 标题栏默认颜色

[英]How to get UWP title bar default colors programmatically

How to get UWP title bar color programmatically?如何以编程方式获取 UWP 标题栏颜色?

I can easy set custom title bar colors with:我可以轻松设置自定义标题栏颜色:

ApplicationView.GetForCurrentView().TitleBar.BackgroundColor
ApplicationView.GetForCurrentView().TitleBar.ForegroundColor 

But how to get system title bar colors?但是如何获取系统标题栏颜色呢? Eg If user set Show color on title bar option and use Yellow as Windows Accent Color then UWP App title bar BackgroundColor is Yellow .例如,如果用户设置Show color on title bar选项并使用Yellow作为 Windows Accent Color,则 UWP App 标题栏BackgroundColorYellow But ApplicationView.GetForCurrentView().TitleBar.BackgroundColor return null .但是ApplicationView.GetForCurrentView().TitleBar.BackgroundColor返回null

Screenshot of win 10 color setting win 10 颜色设置截图

It's AccentColor.这是重点色。 You can get it programmatically您可以通过编程方式获取

var color = new UISettings().GetColorValue(UIColorType.Accent);

or try或尝试

var color = (Color)Resources["SystemAccentColor"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM