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 到 Avalonia 的迁移系列实战篇6:Trigger、MultiTrigger、DataTrigger 的迁移
wpf·avalonia
招风的黑耳2 天前
Java生态圈核心组件深度解析:Spring技术栈与分布式系统实战
java·spring·wpf
lfw20192 天前
WPF 数据绑定模式详解(TwoWay、OneWay、OneTime、OneWayToSource、Default)
wpf
Magnum Lehar2 天前
3d wpf游戏引擎的导入文件功能c++的.h实现
3d·游戏引擎·wpf
FuckPatience3 天前
WPF Telerik.Windows.Controls.Data.PropertyGrid 自定义属性编辑器
wpf
almighty273 天前
C#WPF控制USB摄像头参数:曝光、白平衡等高级设置完全指南
开发语言·c#·wpf·usb相机·参数设置
军训猫猫头4 天前
12.NModbus4在C#上的部署与使用 C#例子 WPF例子
开发语言·c#·wpf
我要打打代码4 天前
在WPF项目中使用阿里图标库iconfont
wpf
拾忆,想起5 天前
Redisson 分布式锁的实现原理
java·开发语言·分布式·后端·性能优化·wpf
weixin_464078075 天前
wpf依赖注入驱动的 MVVM实现(含免费源代码demo)
wpf