有没有办法判断用户是选择了Light还是Dark主题?
谢谢!
答案 0 :(得分:10)
有一个属性可以测试,而不是比较实际的资源颜色。
Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"];
if (v == System.Windows.Visibility.Visible)
{
// Is light theme
}
else
{
// Is dark theme
}
答案 1 :(得分:0)
如果您打算在代码中检测主题,那么这是一个解决方案 -
var backColor = Resources["PhoneBackgroundColor"];
if (backColor.ToString() == "#FF000000")
// Dark theme selected => do something
else
// Light theme selected => do something
HTH, indyfromoz