赞
踩
官网:链接: http://materialdesigninxaml.net.
GitHub源码及DemoApp地址:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/releases.
在NuGet安装MaterialDesignThemes
在App.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>
在需要的窗体内添加:xmlns:materialDesign=“http://materialdesigninxaml.net/winfx/xaml/themes”
<Window x:Class="HostComputer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HostComputer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
1) 打开下载好的DemoApp选择要使用的控件。
2) 复制到程序中
3) 运行效果
添加成功
在App.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> <SolidColorBrush x:Key="PrimaryHueLightBrush" Color="#ffc947"/> <SolidColorBrush x:Key="PrimaryHueLightForegroundBrush" Color="#ffffff"/> <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#ff9800"/> <SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="#ffffff"/> <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#c66900"/> <SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#ffffff"/> </ResourceDictionary> </Application.Resources>
效果
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。