安装 Material Design Themes
-
通过 NuGet 包管理器搜索自动安装
-
通过 NuGet 包管理器控制台手动安装
Install-Package MaterialDesignThemes
配置 App.xaml
-
主题
-
对于 Light 主题(二选一):
< ResourceDictionary Source = “ pack:// application:,,, / MaterialDesignThemes.Wpf; component / Themes / MaterialDesignTheme.Light.xaml ” />
-
对于 Dark 主题(二选一):
< ResourceDictionary Source = “ pack:// application:,,, / MaterialDesignThemes.Wpf; component / Themes / MaterialDesignTheme.Dark.xaml ” />
-
默认
< ResourceDictionary Source = “ pack:// application:,,, / MaterialDesignThemes.Wpf; component / Themes / MaterialDesignTheme.Defaults.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 ” />
配置窗体
-
基础配置
<Window [...] TextElement.Foreground="{DynamicResource MaterialDesignBody}" Background="{DynamicResource MaterialDesignPaper}" [...] >
-
完整配置
<Window [...] TextElement.Foreground="{DynamicResource MaterialDesignBody}" Background="{DynamicResource MaterialDesignPaper}" TextElement.FontWeight="Medium" TextElement.FontSize="14" FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto" [...] >