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