[Windows Phone] specifies the background color (Dark/Light) in the application)

Source: Internet
Author: User

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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.