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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.