SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Windows Phone Application Development Tutorials, Articles and Resources for Mobile App Programmers


How to Detect Windows Phone Accent Color Programmatically by Code

Windows Phone 8 theme enables users to select one of Windows Phone accent colors to set as the theme accent color. It is possible to detect accent color in Windows Phone 8 app development using SettingsApp namespace. Windows Phone app developers want to know and use active accent color in their WP8 apps in order to provide a better look and feel for their apps.

This Windows Phone 8 app development tutorial shows how to find active accent color and use the accent color on app user interface with a sample.

Open Visual Studio 2012 and create a new Windows Phone 8 project using Windows Phone SDK 8.0 templates. On MainPage.xaml place a button. I named the button control as btnAccentColor.

On code behind of MainPage.xaml UI page, within the Constructor method of the app page place the following two lines of code. Be sure that you have imported System.Windows.Media namespace for SolidColorBrush class before you compile the Visual Studio 2012 project.

var phoneAccentBrush = new SolidColorBrush((App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color);

btnAccentColor.Background = phoneAccentBrush;
Code

The first line of C-Sharp code gets the Windows Phone accent color from Settings PhoneAccentBrush property. And it stores the accent color in a new Brush object.

The second code line uses the active Windows Phone 8 accent color for the background color of the button control on app page.

When you compile and run the application, you will see a screen like shown below with the button color is in the accent color you have set on your Windows Phone 8 device or WP8 emulator.

The button background color is successfully set to violet Windows Phone accent color by the above sample code.



Windows 10 Games

Microsoft Games on Windows 8 and Windows 10


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.