Theme Resources

Windows Store and universal apps don’t support DynamicResource, but they can use a ThemeResource mechanism to handle light versus dark app themes or handle switching into and out of the high contrast Windows themes. ThemeResource works like WPF’s DynamicResource, but its refresh behavior is limited to theme changes.

To enable this, ResourceDictionary has a ThemeDictionaries property that can contain separate ResourceDictionarys, one for each possible theme. The correct one automatically gets merged into the host ResourceDictionary based on the current theme. These theme dictionaries can contain any resource, but it’s common for them to contain specific Brushes. The following XAML demonstrates:

<

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.