WPF控件库 MaterialDesignTheme 自定义笔刷颜色简介

有时你会想直接使用Toolkit's里面的Brush在你的项目里,典型的使用方法是作为Dynamic resources使用它们,这样控件可以立刻更新到现在的配色方案

配色方案名字(Palette Brush Names)

基础颜色(Primary Colour)

  • PrimaryHueLightBrush
  • PrimaryHueLightForegroundBrush
  • PrimaryHueMidBrush
  • PrimaryHueMidForegroundBrush
  • PrimaryHueDarkBrush
  • PrimaryHueDarkForegroundBrush

[Light/Mid/Dark]Brush代表了基础颜色的不同色调,[Light/Mid/Dark]ForegroundBrush代表了前景色

着重颜色(Accent Colour)

  • SecondaryAccentBrush
  • SecondaryAccentForegroundBrush

使用范例(Example Usage) 

<TextBlock Foreground="{DynamicResource PrimaryHueMidBrush}" />

亮/黑具体笔刷名字(Light/Dark Specific Brush Names)

  • MaterialDesignBackground
  • MaterialDesignPaper
  • MaterialDesignBody
  • MaterialDesignBodyLight
  • MaterialDesignColumnHeader
  • MaterialDesignCheckBoxOff
  • MaterialDesignCheckBoxDisabled
  • MaterialDesignTextBoxBorder
  • MaterialDesignDivider
  • MaterialDesignSelection
  • MaterialDesignFlatButtonClick
  • MaterialDesignFlatButtonRipple
  • MaterialDesignToolTipBackground
  • MaterialDesignChipBackground

App.xaml 文件配置参考

<Application x:Class="WpfApp1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:local="clr-namespace:WpfApp1" 
             StartupUri="/MainWindow.xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <Application.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>         
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <!--PRIMARY-->
            <SolidColorBrush x:Key="PrimaryHueLightBrush" Color="#349fda"/>
            <SolidColorBrush x:Key="PrimaryHueLightForegroundBrush" Color="#333333"/>
            <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#0288d1"/>
            <SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="#FFFFFF"/>
            <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#015f92"/>
            <SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#FFFFFF"/>
            <!--ACCENT-->
            <SolidColorBrush x:Key="SecondaryAccentBrush" Color="#689f38"/>
            <SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="#FFFFFF"/>


        </ResourceDictionary>
    </Application.Resources>
</Application>

参考 https://www.cnblogs.com/OpenLJW/p/10152015.html

猜你喜欢

转载自blog.csdn.net/zouzh/article/details/104479896