zoukankan      html  css  js  c++  java
  • WPF控件库MaterialDesignInXamlToolkit

    WPF控件库MaterialDesignInXamlToolkit

    引用 MaterialDesignThemes.Wpf.dll

    第一步:安装控件库

    Install-Package MaterialDesignThemes
    

    第二步:配置App.xaml

    你需要合并一个主题(Dark或者Light)到你的资源字典,你只需要添如下代码到你的资源字典就能完成此步骤

    Light theme:

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
    

    Dark theme:

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
    

    第三步:添加色彩

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.COLOR_NAME.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.COLOR_NAME.xaml" />
    

    App.xaml文件

    <Application x:Class="MaterialTest.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 StartupUri="MainWindow.xaml">
        <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>            
            </ResourceDictionary>
        </Application.Resources>
    </Application>
    

    第四步:配置你的主窗口文件

    <Window [...]
            TextElement.Foreground="{DynamicResource MaterialDesignBody}"
            Background="{DynamicResource MaterialDesignPaper}"
            TextElement.FontWeight="Medium"
            TextElement.FontSize="14"
            FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
            [...] >
    
  • 相关阅读:
    Linux学习笔记(二):实战-根据微服务端口号关闭进程
    Linux学习笔记(一):文件操作命令
    算法-Java组合
    Springboot学习笔记(六)-配置化注入
    Springboot学习笔记(五)-条件化注入
    Springboot学习笔记(四)-配置相关
    Springboot学习笔记(三)-常用注入组件方式
    CentOS7安装MySQL
    扫二维码下载apk并统计被扫描次数(及微信屏蔽下载解决方案)
    Java jacob调用打印机打印word文档
  • 原文地址:https://www.cnblogs.com/ouyangkai/p/12753710.html
Copyright © 2011-2022 走看看