Question

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

Thanks!

Was it helpful?

Solution

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
}

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top