Windows Phone 7检测当前主题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows Phone 7检测当前主题相关的知识,希望对你有一定的参考价值。
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.
// 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; } }
以上是关于Windows Phone 7检测当前主题的主要内容,如果未能解决你的问题,请参考以下文章
支持OS 7.0的Windows Phone Xap在市场上检测为7.1
如何检测到 UI 元素(全景和列表框)的数据绑定何时在 windows phone 7 中完成?
如何在 Windows Phone 7 上播放在线声音剪辑?