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"
            [...] >
    
  • 相关阅读:
    P7473 [NOI Online 2021 入门组] 重力球
    CF896D Nephren Runs a Cinema
    [持续更新]一些有趣的数学问题
    [微积分与无穷级数]AMM Problems笔记
    [补题]SWERC-2018
    [补题]Asia Regional Contest, Tokyo, 2014

    [NOI2005]瑰丽华尔兹-单调队列优化DP
    [补题]2017多校D-BD-区间筛/二分+线段树
    [补题]2017多校5A/HDU6085-Rikka with Candies-bitset优化
  • 原文地址:https://www.cnblogs.com/ouyangkai/p/12753710.html
Copyright © 2011-2022 走看看