如何获取UWP-Apps的系统重音颜色? [英] How to get the system accent color for UWP-Apps?
问题描述
我想在Windows 10的UWP应用程序中获得用户的重音颜色。我知道如何获得它在C#,但我开发我的应用程序在WinJS。因此,任何人都知道WinJS等价于 var color =(Color)Application.Current.Resources [SystemAccentColor];
?
I'm trying to get the Accent Color of a user in a UWP-App for Windows 10. I know how to get it in C#, but I develop my apps in WinJS. So does anyone knows the WinJS equivalent for var color = (Color)Application.Current.Resources["SystemAccentColor"];
?
这也将是很好,如果我可以访问此颜色与CSS。我发现一些提示, color:Highlight;
将是解决方案,但这只给我一个蓝色,而不是Accent颜色。
It would also be nice, if I could Access this Color with CSS. I found some hints, that color: Highlight;
would be the solution, but this gives me only a blue and not the Accent Color.
感谢alot。
推荐答案
您可以使用WinRT API:Windows.UI.ViewManagement.UIColorType枚举提供所有的口音颜色。你可以像下面这样:
you can use WinRT API to do that : Windows.UI.ViewManagement.UIColorType enumeration provides all accents colors. You can make something like :
var uiSettings = new Windows.UI.ViewManagement.UISettings();
var rgba = uiSettings.getColorValue(Windows.UI.ViewManagement.UIColorType.accent);
var cssColorString = "rgba(" + rgba.r + "," + rgba.g + "," + rgba.b + ", " + rgba.a + ")";
这篇关于如何获取UWP-Apps的系统重音颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!