WPF MaterialDesign 界面美化

准备

修改 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>

接着修改 MainWindows.xaml

<Window ...>
...
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}" MouseDown="Window_MouseDown" WindowStartupLocation="CenterScreen"
...
</Window>

使用控件

具体控件的使用方法参考 MaterialDesignInXamlToolkitDemoApp
Demo下载

文章作者: NiTian
文章链接: https://www.nitian1207.top/2019/09/24/WPF-MaterialDesign-界面美化/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 NiTian的小窝
支付宝打赏
微信打赏