/ Published in: C#
Add this code to your App.xaml.cs inside your App class to enable a static property that will give you the current theme at runtime.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// An enum to specify the theme. public enum AppTheme { Dark = 0, Light = 1 } // Detecting the current theme. private static Color lightThemeBackground = Color.FromArgb(255, 255, 255, 255); private static Color darkThemeBackground = Color.FromArgb(255, 0, 0, 0); private static SolidColorBrush backgroundBrush; internal static AppTheme CurrentTheme { get { if ( backgroundBrush == null ) backgroundBrush = Application.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush; if (backgroundBrush.Color == lightThemeBackground) return AppTheme.Light; else if (backgroundBrush.Color == darkThemeBackground) return AppTheme.Dark; return AppTheme.Dark; } }
URL: http://jacob4u2.blogspot.com