【问题标题】:Changing Material Design Icon and Text to Primary Color将 Material Design 图标和文本更改为原色
【发布时间】: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


    【解决方案1】:

    您将找到 Primary* 画笔资源here

    <materialDesign:PackIcon x:Name="iconWarning" Width="25" Height="25" Margin="5" Kind="Warning"
                             Foreground="{StaticResource PrimaryHueMidBrush}" />
    <TextBlock x:Name="lblWarning" Text="Warning" HorizontalAlignment="Left" VerticalAlignment="Center"
               Margin="5" Padding="5"
               Foreground="{StaticResource PrimaryHueMidBrush}" />
    

    【讨论】:

      猜你喜欢
      • 2017-05-09
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 2021-02-22
      • 1970-01-01
      相关资源
      最近更新 更多