• WPF 扩展MaterialDesignTheme主题


    项目中用到了MaterialDesignTheme,他只有两种主题,light和dark。

    查看源码,将他dark主题copy到我们项目中

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
    
        <Color x:Key="MaterialDesignValidationErrorColor">#f44336</Color>
        <SolidColorBrush x:Key="MaterialDesignValidationErrorBrush" Color="{StaticResource MaterialDesignValidationErrorColor}"/>
    
        <SolidColorBrush x:Key="MaterialDesignBackground" Color="#FF000000" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignPaper" Color="#FF303030" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignCardBackground" Color="#FF424242" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignToolBarBackground" Color="#FF212121" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignBody" Color="#DDFFFFFF" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignBodyLight" Color="#89FFFFFF" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignColumnHeader" Color="#BCFFFFFF" po:Freeze="True" />
    
        <SolidColorBrush x:Key="CommonBodyForeground" Color="White"/>
        <SolidColorBrush x:Key="CommonBorderBursh" Color="#FF4B9598" />
        <!-- 74% -->
    
        <SolidColorBrush x:Key="MaterialDesignCheckBoxOff" Color="#89FFFFFF" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignCheckBoxDisabled" Color="#FF647076" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignTextBoxBorder" Color="#89FFFFFF" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignDivider" Color="#1FFFFFFF" po:Freeze="True" />
        <!-- 12% -->
        <SolidColorBrush x:Key="MaterialDesignSelection" Color="#757575" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignToolForeground" Color="#616161" po:Freeze="true" />
        <SolidColorBrush x:Key="MaterialDesignToolBackground" Color="#e0e0e0" po:Freeze="true" />
    
        <SolidColorBrush x:Key="MaterialDesignFlatButtonClick" Color="#19757575" po:Freeze="True" />
        <!-- 25% -->
        <SolidColorBrush x:Key="MaterialDesignFlatButtonRipple" Color="#FFB6B6B6" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignToolTipBackground" Color="#eeeeee" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignChipBackground" Color="#FF2E3C43" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarBackground" Color="#FFCDCDCD" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarMouseOver" Color="#FFB9B9BD" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarRipple" Color="#FF494949" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxBackground" Color="#1AFFFFFF" po:Freeze="True" />
        <!-- 10% white -->
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxHoverBackground" Color="#1FFFFFFF" po:Freeze="True" />
        <!-- 12% white -->
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxDisabledBackground" Color="#0DFFFFFF" po:Freeze="True" />
        <!-- 5% white -->
        <SolidColorBrush x:Key="MaterialDesignTextAreaBorder" Color="#BCFFFFFF" po:Freeze="True" />
        <!-- 74% white -->
        <SolidColorBrush x:Key="MaterialDesignTextAreaInactiveBorder" Color="#29FFFFFF" po:Freeze="True" />
        <!-- 41% white (= 74% * 56%) -->
    
        <SolidColorBrush x:Key="MaterialDesignDataGridRowHoverBackground" Color="#14FFFFFF" po:Freeze="True" />
        <!-- 8% white -->
    </ResourceDictionary>

     复制这个Theme.Dark.xaml文件,重命名为Theme.DarkBule.xaml,修改里面的颜色

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
    
        <Color x:Key="MaterialDesignValidationErrorColor">#f44336</Color>
        <SolidColorBrush x:Key="MaterialDesignValidationErrorBrush" Color="{StaticResource MaterialDesignValidationErrorColor}"/>
    
        <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#FF252525"/>
        <SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="White"/>
        <SolidColorBrush x:Key="MaterialDesignBody" Color="#FF252525"/>
        <SolidColorBrush x:Key="MaterialDesignPaper" Color="#FF55AAAD"/>
        <SolidColorBrush x:Key="CommonBodyForeground" Color="White"/>
        <SolidColorBrush x:Key="CommonBorderBursh" Color="#FF4B9598" />
        <SolidColorBrush x:Key="MaterialDesignColumnHeader" Color="#FF252525"/>
        <SolidColorBrush x:Key="MaterialDesignDivider" Color="#FF4B9598" />
        <SolidColorBrush x:Key="MaterialDesignSelection" Color="#FF4B9598"   />
    
        <SolidColorBrush x:Key="MaterialDesignBackground" Color="#FF000000" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignCardBackground" Color="#FF424242" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignToolBarBackground" Color="#FF212121" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignBodyLight" Color="#89FFFFFF" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignCheckBoxOff" Color="#89FFFFFF" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignCheckBoxDisabled" Color="#FF647076" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignTextBoxBorder" Color="#89FFFFFF" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignToolForeground" Color="#616161" po:Freeze="true" />
        <SolidColorBrush x:Key="MaterialDesignToolBackground" Color="#e0e0e0" po:Freeze="true" />
    
        <SolidColorBrush x:Key="MaterialDesignFlatButtonClick" Color="#19757575" po:Freeze="True" /> <!-- 25% -->
        <SolidColorBrush x:Key="MaterialDesignFlatButtonRipple" Color="#FFB6B6B6" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignToolTipBackground" Color="#eeeeee" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignChipBackground" Color="#FF2E3C43" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarBackground" Color="#FFCDCDCD" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarMouseOver" Color="#FFB9B9BD" po:Freeze="True" />
        <SolidColorBrush x:Key="MaterialDesignSnackbarRipple" Color="#FF494949" po:Freeze="True" />
    
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxBackground" Color="#1AFFFFFF" po:Freeze="True" /> <!-- 10% white -->
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxHoverBackground" Color="#1FFFFFFF" po:Freeze="True" /> <!-- 12% white -->
        <SolidColorBrush x:Key="MaterialDesignTextFieldBoxDisabledBackground" Color="#0DFFFFFF" po:Freeze="True" /> <!-- 5% white -->
        <SolidColorBrush x:Key="MaterialDesignTextAreaBorder" Color="#BCFFFFFF" po:Freeze="True" /> <!-- 74% white -->
        <SolidColorBrush x:Key="MaterialDesignTextAreaInactiveBorder" Color="#29FFFFFF" po:Freeze="True" /> <!-- 41% white (= 74% * 56%) -->
    
        <SolidColorBrush x:Key="MaterialDesignDataGridRowHoverBackground" Color="#14FFFFFF" po:Freeze="True" /> <!-- 8% white -->
    </ResourceDictionary>

    用法:

     

    如图,把他官方的,调用主题的那行注释掉,添加一行source指定到我们扩展的主题文件。

     

     配色忽略,没有美工....

  • 相关阅读:
    拓端tecdat|R语言分类回归决策树交互式修剪和更美观地可视化分析细胞图像分割数据集
    使用 Databricks 进行营销效果归因分析的应用实践【Databricks 数据洞察公开课】
    关于 Data Lake 的概念、架构与应用场景介绍
    基于EasyCV复现ViTDet:单层特征超越FPN
    使用Databricks+Mlflow进行机器学习模型的训练和部署【Databricks 数据洞察公开课】
    数据湖构建—如何构建湖上统一的数据权限
    团队管理|如何提高技术Leader的思考技巧?
    StarRocks X Flink CDC,打造端到端实时链路
    全文检索工具:第一章:SpringdataelasticSearch搜索
    Docker:第一章:Docker常用命令
  • 原文地址:https://www.cnblogs.com/czly/p/14776099.html
Copyright © 2020-2023  润新知