【发布时间】:2020-12-22 23:37:12
【问题描述】:
这是我第一次使用材料设计,虽然一切都非常有效,但我对图标颜色有点困惑。
在我的 App.xaml 中,我有以下资源字典;
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Grey.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Yellow.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
在我的表单上,我有一个图标和文本块;
<DockPanel>
<materialDesign:PackIcon x:Name="iconWarning" Width="25" Height="25" Margin="5" Kind="Warning" Foreground="OrangeRed" />
<TextBlock x:Name="lblWarning" Text="Warning" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Padding="5" Foreground="OrangeRed"/>
</DockPanel>
但是,在我的 C# 代码中,我有一个方法可以更改正在使用的主题,也可以更改主色和辅助色。但是,我如何设置我的文本块和图标以使用原色,类似于设置颜色区域的方式,例如使用模式与必须使用 Foreground="OrangeRed";
Mode="PrimaryMid"
【问题讨论】:
标签: c# wpf material-design