Dean Chalk
Dean Chalk

Reputation: 20451

Windows 8 theme color - accessing it programmatically

In windows 8 consumer preview you can personalize your experience, including setting a 'background color' which is then also used as the background for selected tiles, app bar etc. So selecting orange will mean that orange accents are visible in the Windows 8 Metro UI.

I am currently authoring some custom controls, and I would like to have access to this color in my styling, so as the user changes color so my applications accents are re-colored accordingly.

I cannot find a way of getting at this color in my XAML. It seems reasonable to expect that there is a system-level dynamic brush or color resource that you could reference.

Does anyone have any ideas ?

Upvotes: 12

Views: 6663

Answers (3)

Filip Skakun
Filip Skakun

Reputation: 31724

Based on this thread (Start Screen background as my metro apps background) on MSDN - this is not available.

In case the MSDN thread disappears, the site is temporarily unavailable, or Microsoft moves the directory structure around and leaves orphaned links all over the place: The relevant answer there, from Microsoft employee Rob Kaplan, said:

Metro style apps cannot query the start screen background color.

So it can be construed as an official response that this functionality is unavailable.

Upvotes: 7

Quppa
Quppa

Reputation: 1913

There are some undocumented APIs in UxTheme.dll that retrieve theme colours. If you use these functions and submit your app to the Windows Store it will fail certification, and in general it's a bad idea to rely on undocumented functions anyway. Still, for those interested in getting these values, I wrote about the process.

Upvotes: 2

Thomas Mullen
Thomas Mullen

Reputation: 101

Alan,

While I would agree with you that the "branding" concept makes good sense if you are planning on complex graphic overlays, getting the base theme color as is available on the Windows Phone using a static theme brush provided by the OS is a better choice for base color themes in your app. The user has chosen that color because they find it pleasing to the eye. Even more important, certain users may be color blind to one or more colors and have chosen the best option to enhance readability and accessibility.

Having access to the standard color scheme allows you to stay within the light/dark theme and meet the accessibility standards required by many corporations for all programs for those that are visually impaired.

The SDK is in it's infancy and it is possible that this important feature has been left out of the current implementation because it was not ready for the release of the SDK (colors might not have been finalized or compatibility of the theme on certain devices was still being developed).

It isn't too difficult to derive the theme color from an existing theme brush that is given to you such as ProgressBarForegroundThemeBrush by adding/subtracting values to get the current theme color.

My suggestion would be to adhere to the theme styles as best as possible to ensure your application will remain current regardless of changes to the operating system.

I have been a Windows Phone programmer since May 2010.

Upvotes: 5

Related Questions