MaterialDesignInXamlToolkit 是一套非常漂亮的开源WPF UI控件,而且Demo也很全面,简单易用!
一、源码和Demo
源码地址:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit
Demo地址:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/releases
使得说明:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/wiki/Getting-Started
二、从Nuget安装
搜索 MaterialDesignThemes 并选择安装
三、使用
和所有程序一样,WPF也有入口,打开App.xaml,加上命令空间:xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 和资源
<Application x:Class="CTTools.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CTTools"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Indigo" SecondaryColor="Lime" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
然后就可以在MainWindow.xaml进行窗体编辑和写相关程序了。如果想偷懒甚至可以直接从Demo里copy下来,自己再调整
这个Demo可以从我上面发出来的链接中找到
最后写了个小工具,这套UI还是挺漂亮的,效果如下: