如何获取UWP-Apps的系统重音颜色? [英] How to get the system accent color for UWP-Apps?

查看:314
本文介绍了如何获取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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆