C# WPF Material DesignThemes 5.0 命名规则改变后导致找不到资源

复制代码
	MaterialDesignInXAML库从5.0.0版本开始的命名规则变化,使用新的ResourceDictionary时遇到的themes/materialdesigntheme.defaults.xaml找不到.

原本在App.xaml中定义如下:

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

自5.0.0版本更新后,命名方式改变,两条引用找不到。

复制代码
	Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"

Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml"

这两条改为:

复制代码
	Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml"

	Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml"

最终整个Application.ResourcessourceDictionary>

复制代码
  <ResourceDictionary.MergedDictionaries>

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />

  </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

相关推荐
咪咪渝粮2 分钟前
JavaScript 中constructor 属性的指向异常问题
开发语言·javascript
最初的↘那颗心3 分钟前
Java HashMap深度解析:原理、实现与最佳实践
java·开发语言·面试·hashmap·八股文
后台开发者Ethan1 小时前
Python需要了解的一些知识
开发语言·人工智能·python
常利兵2 小时前
Kotlin作用域函数全解:run/with/apply/let/also与this/it的魔法对决
android·开发语言·kotlin
幼稚园的山代王2 小时前
Kotlin-基础语法练习一
android·开发语言·kotlin
重生成为编程大王2 小时前
Java ConcurrentHashMap 深度解析
java·开发语言
tanyongxi663 小时前
C++ 特殊类设计与单例模式解析
java·开发语言·数据结构·c++·算法·单例模式
遗憾皆是温柔3 小时前
24. 什么是不可变对象,好处是什么
java·开发语言·面试·学习方法
wearegogog1233 小时前
C语言中的输入输出函数:构建程序交互的基石
c语言·开发语言·交互
Fine姐3 小时前
The Network Link Layer: 无线传感器中Delay Tolerant Networks – DTNs 延迟容忍网络
开发语言·网络·php·硬件架构