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>

相关推荐
一线码农16 分钟前
MinHook 如何对 .NET 母体 CoreCLR 进行拦截
c#·.net·代码注入
【ql君】qlexcel29 分钟前
Notepad++ 复制宏、编辑宏的方法
开发语言·javascript·notepad++··宏编辑·宏复制
Zevalin爱灰灰38 分钟前
MATLAB GUI界面设计 第六章——常用库中的其它组件
开发语言·ui·matlab
冰糖猕猴桃1 小时前
【Python】进阶 - 数据结构与算法
开发语言·数据结构·python·算法·时间复杂度、空间复杂度·树、二叉树·堆、图
佛·追命1 小时前
.net wpf混淆
.net·wpf
wt_cs1 小时前
银行回单ocr api集成解析-图像文字识别-文字识别技术
开发语言·python
_WndProc2 小时前
【Python】Flask网页
开发语言·python·flask
liujing102329292 小时前
Day04_刷题niuke20250703
java·开发语言·算法
能工智人小辰2 小时前
二刷 苍穹外卖day10(含bug修改)
java·开发语言
DKPT2 小时前
Java设计模式之结构型模式(外观模式)介绍与说明
java·开发语言·笔记·学习·设计模式