Supporting high-contrast themes (Windows Store apps using C#/VB/C++ and XAML)
A Windows Store app built for Windows using C++, C#, or Visual Basic supports high-contrast themes by default. If a user has chosen that they want the system to use a high-contrast theme from Windows 8 system settings or accessibility tools, the framework automatically uses colors and style settings that produce a high-contrast layout and rendering for controls and components in the UI.
This default support is based on using the default themes for the default controls. These themes make references to system colors as resource definitions, and the resource sources change automatically when the system is using a high-contrast mode. However, if you use custom templates, themes, and styles for your control, be careful that you do not disable the built-in support for high contrast. If you use Blend for Microsoft Visual Studio 2012 for Windows 8 for styling, Blend generates a separate, high-contrast theme alongside the primary theme whenever you define a template that is significantly different from the default template. The separate theme dictionaries go into ThemeDictionaries, a dedicated property of a ResourceDictionary element.
For more info on themes and control templates, see Quickstart: Control templates. It's often very informative to look at the XAML resource dictionaries and themes for specific controls and see how the themes are constructed and how they reference resources that are similar but different for each possible high-contrast setting.
A Windows Store app can use members of the AccessibilitySettings class to detect the current settings for high-contrast themes. The HighContrast property determines whether a high-contrast theme is currently selected. If HighContrast is true, then the next step is to check the value of the HighContrastScheme property to get the name of the high-contrast theme that is used. "High Contrast White" and "High Contrast Black" are typically values for HighContrastScheme that your code should respond to. XAML-defined ResourceDictionary keys can't have spaces, so the keys for these themes in a resource dictionary are typically "HighContrastWhite" and "HighContrastBlack" respectively. You should also have fallback logic for a default high-contrast theme in case the value is some other string. XAML high contrast sample shows the logic for this.
Note For a Windows Store app built for Windows using C++, C#, or Visual Basic, themes and resources are not automatically reloaded if the user switches to a high-contrast mode while the app is running. Users typically are using high-contrast settings as a preference and don't routinely turn these settings on and off during a session.
- UI contrast and settings sample
- XAML accessibility sample
- XAML high contrast sample
Build date: 11/29/2012