1. 添加 NuGet 包
在解決方案管理器視圖中的目標項目上右鍵 -> 管理 NuGet 程序包;
添加 MaterialDesignThemes 包,如下圖所示:

2. 配置 App.xaml
App.xaml 應該是類似這樣的:
更改此處來更改主題和顏色 BaseTheme="Light" PrimaryColor="Aqua" SecondaryColor="DarkGreen"
<Application x:Class="Example.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 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>
3. 配置 Window
向窗口的開始標簽添加一些參數。為了獲得完整的材質設計體驗,你應該這樣設置字體:
<Window [...] xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" TextElement.Foreground="{DynamicResource MaterialDesignBody}" Background="{DynamicResource MaterialDesignPaper}" TextElement.FontWeight="Medium" TextElement.FontSize="14" FontFamily="{materialDesign:MaterialDesignFont}" [...] >
4. 開始使用
打開從 GitHub 上下載的 MaterialDesignDemo.exe 查看控件效果和代碼。
Demo 下載地址:https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/releases
GitHub 地址:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit
5. 參考
官方入門指導:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/wiki/Getting-Started
