当前位置: 首页 > news >正文

WPF上使用MaterialDesign框架---下载与配置

一、介绍:
Material Design语言的一些重要功能包括 系统字体Roboto的升级版本 ,同时颜色更鲜艳,动画效果更突出。杜拉特还简要谈到了新框架的一些变化。谷歌的想法是让谷歌平台上的开发者掌握这个新框架,从而让所有应用就有统一的外观,就像是苹果向开发者提出的设计原则一样。谷歌还基于这种新的设计语言对本公司旗舰应用进行了重新设计,包括安卓和网页端的Gmail和Calendar。大家可能还会记得,最近曾看到过有关这些变动的文章, 有些博客 已经掌握了外泄截屏,显示经过了重新设计的Gmail,界面更干净、更简约。在安卓平台上,这种新界面被称为Material,支持各种新动画效果,具有内置的实时UI阴影,以及可在不同屏幕之间切换的hero元素。-----这部分属于摘抄。
二、Material Design在WPF上下载
1.新建一个WPF项目:
由于我安装的是VS2022版本,所以我新建的项目版本是.NET6.0。
在这里插入图片描述

2.下载Material Design包:
点击项目,选择管理NuGet程序包…
在这里插入图片描述搜索Material Design,点击安装:
在这里插入图片描述

三、.配置App.xaml
按照网上其他博主介绍,是添加以下内容:

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

在我这里,始终都会报错,如下图:
在这里插入图片描述
试了好久,最后找到官方文档,得到解决,将上面内容换成如下:

        <ResourceDictionary><ResourceDictionary.MergedDictionaries><materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="DeepPurple" SecondaryColor="Lime" /><ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" /></ResourceDictionary.MergedDictionaries></ResourceDictionary>

完整App.xaml:

<Application x:Class="WpfApp1.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:WpfApp1" 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/MaterialDesign3.Defaults.xaml" /></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources>
</Application>

四、官方DemoAPP
该EXE提供了各种控件的样式和xaml代码,如下图:
在这里插入图片描述
点击左侧菜单栏,可以选择不同控件
在这里插入图片描述
点击不同控件上的小图标会显示控件代码,直接复制使用:
在这里插入图片描述

五、控件添加界面
1.先在前端引用: xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
2.可以根据DemoApp上进行复制,至此完美结束。

http://www.lryc.cn/news/329149.html

相关文章:

  • 鸿蒙ARKTS--简易的购物网站
  • LabVIEW转动设备故障诊断系统
  • uniapp h5 touch事件踩坑记录
  • webpack.prod.js(webpack生产环境配置文件)
  • 利用python做模拟数据(测试数据),连接数据库和服务器接口,涉及雪花id服务
  • 大模型日报2024-03-30
  • 【ARM 嵌入式 C 入门及渐进 14 -- C 代码中取余与取模的使用介绍】
  • C++入门知识详细讲解
  • pytorch中的torch.hub.load():以vggish为例
  • mysql 用户管理-权限管理
  • RabbitMQ--04--发布订阅模式 (fanout)-案例
  • 基于java+SpringBoot+Vue的网上书城管理系统设计与实现
  • PCL点云处理之M估计样本一致性(MSAC)平面拟合(二百三十六)
  • 通过WSL在阿里云上部署Vue项目
  • 240330-大模型资源-使用教程-部署方式-部分笔记
  • uni-app 富文本编辑器
  • 3D汽车模型线上三维互动展示提供视觉盛宴
  • 如何在Flutter中进行网络请求?
  • node:ReferenceError: XMLHttpRequest is not defined
  • PHP定时任务框架taskPHP3.0的学习记录1(TaskPHP、执行任务类的实操代码实例)
  • 图腾柱PFC:HP1010为您的电动两轮车之旅提供绿色,高效,安全的动力
  • 动态规划-----背包类问题(0-1背包与完全背包)详解
  • 通过 Docker 搭建 BookStack
  • 通俗易懂:什么是Java虚拟机(JVM)?它的主要作用是什么?
  • [k8s] kubectl执行失败后等待一段时间再重试 (Shell实现)
  • java中的static和单例模式
  • RabbitMQ相关总结
  • RAFT: Adapting Language Model to Domain Specific RAG
  • 第十五届蓝桥杯第三期模拟赛第十题 ← 上楼梯
  • 第四题:星期一