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给的方案去解决。侵入式太强,不太喜欢,还是自己写好一点。

相关推荐
yantuguiguziPGJ1 小时前
WPF 联合 Web 开发调试流程梳理(基于 Microsoft.Web.WebView2)
前端·microsoft·wpf
Aevget1 小时前
DevExpress WPF中文教程:Data Grid - 如何使用虚拟源?(二)
.net·wpf·界面控件·devexpress·ui开发·数据网格
大美B端工场-B端系统美颜师7 小时前
工控软件开发选择难?Electron、Qt、WPF 对比
qt·electron·wpf
c#上位机8 小时前
MefBootstrapper在Prism引导程序中的使用
c#·wpf·prism
没有bug.的程序员1 天前
服务治理与 API 网关:微服务流量管理的艺术
java·分布式·微服务·架构·wpf
Brianna Home2 天前
【案例实战】鸿蒙分布式调度:跨设备协同实战
华为·wpf·harmonyos
c#上位机3 天前
wpf中Grid的MouseDown 事件无法触发的原因
c#·wpf
△曉風殘月〆3 天前
如何在WPF中实现ComboBox多选
wpf
csdn_aspnet3 天前
如何使用现有工具进行 .NET 8 迁移 Wpf
wpf·.net 8
123梦野3 天前
WPF——动画
wpf