更新时间:2023-01-27 17:39:51
这种方法不如限定符方便,但有效.
This aproach isn't as convenient as qualifiers, but it works.
在 App.xaml 中定义
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>
然后使用
<Image Source="{ThemeResource Logo}"/>