Dark / Light Categories

I have a very simple requirement for using dark / dark images. I was expecting a type qualifier

SomeImage.Theme-Light.png 

or put an image under a folder called Theme-Light

 Theme-Light/SomeImage.png 

will work, and it happened, but only in design mode. As soon as I launch the application, despite the fact that the required theme is correctly configured (both at the application level and at the page level, so that all other themes load correctly), the wrong image is loaded.

I know about workarounds for loading different images for different themes so that is not what I am looking for. I am curious to know why this approach with qualifiers does not work at runtime? Is there another name classifier?

I read this article: “ How to Name Resources Using Qualifiers (XAML),” but it only shows how to name assets with respect to high contrast support.

+7
c # xaml win-universal-app
source share
1 answer

This aproach is not as convenient as qualifiers, but it works.

Define in App.xaml

 <ResourceDictionary> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Light"> <ImageSource x:Key="Logo">/Assets/Logo-White.png</ImageSource> </ResourceDictionary> <ResourceDictionary x:Key="Dark"> <ImageSource x:Key="Logo">/Assets/Logo-Blue.png</ImageSource> </ResourceDictionary> <ResourceDictionary x:Key="HighContrast"> <ImageSource x:Key="Logo">/Assets/Logo-White.png</ImageSource> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries> </ResourceDictionary> 

Then use

 <Image Source="{ThemeResource Logo}"/> 
+2
source share

All Articles