WPF Material Design 初次使用

文章目录

前言

MD全称MaterialDesignInXamlToolkit,MaterialDesign和Bootstrap一样,都是一个UI风格库。相当于衣服中的休闲服,汉服,牛仔裤一样,就是风格不一样的Ui框架

相关资源


Github 地址

MD 实例资源下载地址

快速开始

快速开始说明地址

如果是普通的WPF程序,在App.xaml里面进行如下设置

xml 复制代码
<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="DeepPurple" SecondaryColor="Lime" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> 
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

打开示例Demo

MainWindow.xaml代码如下

html 复制代码
<Window x:Class="WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:local="clr-namespace:WPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button
                IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
                Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
                ToolTip="MaterialDesignFloatingActionMiniLightButton">
            <materialDesign:PackIcon Width="30"
                                     Height="30"
                                     Kind="Alarm" />
        </Button>
    </Grid>
</Window>

说明导入成功

可以在左侧使用想要的组件,用于快速UI开发,点击右下角都有点击事例代码

吐槽一下

Prism是侵入式框架,就是它给了你全套的解决方案,但是你必须按照Prism给的方案去解决。侵入式太强,不太喜欢,还是自己写好一点。

相关推荐
暮雪倾风1 小时前
【WPF开发】如何设置窗口背景颜色以及背景图片
ui·wpf
暮雪倾风14 小时前
【WPF开发】超级详细的“文件选择”(附带示例工程)
windows·wpf
明耀18 小时前
WPF RadioButton 绑定boolean值
c#·wpf
暮雪倾风19 小时前
【WPF开发】控件介绍-Grid(网格布局)
windows·wpf
芝麻科技2 天前
使用ValueConverters扩展实现枚举控制页面的显示
wpf·prism
笑非不退3 天前
Wpf Image 展示方式 图片处理 显示
开发语言·javascript·wpf
△曉風殘月〆3 天前
在WPF中实现多语言切换的四种方式
wpf·多语言切换
笑非不退3 天前
WPF C# 读写嵌入的资源 JSON PNG JPG JPEG 图片等资源
c#·wpf
He BianGu3 天前
演示:基于WPF的DrawingVisual开发的频谱图和律动图
wpf·示波器·曲线图·频谱分析仪·频谱图·高性能曲线·自绘
笑非不退6 天前
WPF 设计属性 设计页面时实时显示 页面涉及集合时不显示处理 设计页面时显示集合样式 显示ItemSource TabControl等集合样式
wpf