문제

Is there a way to tell if the user has selected a Light or Dark theme?

Thanks!

도움이 되었습니까?

해결책

There is a property to test for this, rather that comparing the actual resource color.

Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"]; 

if (v == System.Windows.Visibility.Visible)
{
    // Is light theme
}
else
{
    // Is dark theme
}

다른 팁

If you intend to detect the theme in code, then here is a solution -

var backColor = Resources["PhoneBackgroundColor"];
if (backColor.ToString() == "#FF000000")
    // Dark theme selected => do something
else
    // Light theme selected => do something

HTH, indyfromoz

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top