MaterialDesignThemes
小于 1 分钟
MaterialDesignThemes
参考资料
- 官方文档:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/wiki
- github源代码和 Demo 下载地址:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/releases
- 使用 Demo 可以直接复制前端代码,从源码中可以直接复制后端代码
使用步骤
通过 Nuget 安装 MaterialDesignThemes
在 App.xaml 中添加资源文件和命名空间
<Application . . . xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="DeepPurple" SecondaryColor="Lime" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>
在 MainWindow.xaml 中添加控件测试
<Window . . . xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"> <StackPanel> <materialDesign:Card Padding="32" Margin="16"> <TextBlock Style="{DynamicResource MaterialDesignHeadline6TextBlock}">My First Material Design App</TextBlock> </materialDesign:Card> </StackPanel> </Window>