我正在使用MahApps Metro主题,除了填充之外,一切都很好。我想将填充颜色绑定到主题中的颜色,并根据明暗模式之间的变化进行更改。有谁知道如何做到这一点?
我的App.xaml:
<Application
...>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
...
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
我想改变什么:
<Rectangle Fill="??????"">
你在Application.Resources里面放了:
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="RectangleFill" Color="White"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="RectangleFill" Color="Blue"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
然后你应该将Rectangle.Fill绑定到ThemeResource“RectangleFill”
<Rectangle Height="200" Width="400" Fill="{ThemeResource RectangleFill}"></Rectangle>