zoukankan      html  css  js  c++  java
  • 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指定到我们扩展的主题文件。

     

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

  • 相关阅读:
    C# 设计模式
    FutureTask、Fork/Join、 BlockingQueue
    线程的几种创建方式
    行锁、表锁、乐观锁、悲观锁
    J.U.C之AQS
    同步容器并发容器
    线程不安全类
    线程封闭
    不可变对象
    安全发布对象—单例模式
  • 原文地址:https://www.cnblogs.com/czly/p/14776099.html
Copyright © 2011-2022 走看看