Preface:After N years of development work, I found that I had not accumulated anything. If I encountered any problems, I went to goole and baidu. Er, it seems that there are many 360so projects. What are the results? Use it after check, and "throw" when used up ". we still need to accumulate a little bit. I have written a few essays before, but it's always a matter of time. this may be a real time, so I added a new [Tips] category and slowly recalled .... write down some technical points used yesterday and today. for your reference, and for future reference.
On Windows Phone, Theme is preset to Dark (Dark) when almost all mobile phones are delivered, which helps save energy on the screen of AMOLED.
However, apps built in Windows Phone, such as Outlook (Hotmail on WP7), Office, and Xbox Live, do not use the background color set by the system. it will use a white background with dark text, and it looks like Light.
Based on this, we can also achieve this effect in our own applications, regardless of the system settings to force the background color to what we need. jeff Wilcox provides us with a class library (PhoneThemeManager) to implement this function, see http://www.jeff.wilcox.name/2012/01/phonethememanager.
Let's take a look at the effect.
The four figures show the original system settings. when running the program, click "ToDark" and click "ToLight". We can see that themanager can also be set when running the program.
Easy to use
First of all, add reference to the installation package. The above introduction link will not be described here.
It is easy to use in program code. You only need to add a line of call to the App constructor:
App constructor public App () {// Global handler for uncaught exceptions. unhandledException + = Application_UnhandledException; // Standard XAML initialization InitializeComponent (); // Phone-specific initialization InitializePhoneApplication (); // Language display initialization InitializeLanguage ();ThemeManager. ToLightTheme ();}
The following is the code in the two buttons. Nobody should be bored to switch the background color in the application. Here we just did a test,
Buttonprivate void btnToDark_Tap(object sender, System.Windows.Input.GestureEventArgs e){ ThemeManager.ToDarkTheme();}private void btnToLight_Tap(object sender, System.Windows.Input.GestureEventArgs e){ ThemeManager.ToLightTheme();}
In addition, Theme Manager provides other functions, which can be further explored by readers.