我正在使用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="??????"">
答案 0 :(得分:1)
在您的应用程序内部。您投入的资源:
<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>