Skip to content

Instantly share code, notes, and snippets.

Last active Dec 17, 2015
What would you like to do?
This class can be copied into any of your phone applications. I usually create a file called Theme.cs and paste it in there. In the App.xaml.cs file, update Application_Launching and Application_Activeated to call Theme.Detect(). This will call the static method called Detect which will, in turn, populate the properties listed. I've blogged abou…
public static class Theme
public static SolidColorBrush Foreground { get; private set; }
public static ThemeColor CurrentTheme { get; private set; }
public static bool IsLightTheme { get { return CurrentTheme == ThemeColor.Light; } }
public static bool IsDarkTheme { get { return CurrentTheme == ThemeColor.Dark; } }
public enum ThemeColor
public static void Detect()
// Determine what the theme background is
Visibility isVisible = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"];
CurrentTheme = isVisible == Visibility.Visible ? ThemeColor.Light : ThemeColor.Dark;
// Determine the theme foreground
Theme.Foreground = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment