will
will

Reputation: 4063

How to tell if the user has selected a Light or Dark theme

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

Thanks!

Upvotes: 5

Views: 787

Answers (2)

Matt Lacey
Matt Lacey

Reputation: 65564

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
}

Upvotes: 10

indyfromoz
indyfromoz

Reputation: 3763

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

Upvotes: 0

Related Questions