使用资源进行主题化而无需混合呕吐 [英] Theming using resources without Blend vomitting

查看:79
本文介绍了使用资源进行主题化而无需混合呕吐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WPF很棒,因为我应该能够在整个应用程序中使用{StaticResource MyBackground}而不是"White",然后通过更改资源定义来重新定义整个应用程序的外观.

WPF is great in that I should be able to use {StaticResource MyBackground} instead of "White" throughout my app, and then by changing resource definitions redefine the look of my entire application.

问题在于,如果您在子控件中引用了全局资源,则Expression Blend将无法正常工作.还有其他方法可以为您的应用程序主题化吗?我不愿意失去Blend Designer的支持,也不愿意在每个控件中复制一段代码/xaml.令他们惊讶的是,他们还没有修复这么大的漏洞.

Problem is Expression Blend just won't work if you have references to global resources in a subcontrol. Is there any other way of theme-ing your app? I am not willing to lose Blend designer support, or replicate a piece of code/xaml in every single control. I find it astounding that they have not fixed a bug of this magnitude.

有什么想法吗?

欢呼

推荐答案

如果您改为使用DynamicResources,似乎该错误消失了.

Seems like this bug disappears if you use DynamicResources instead.

在b)中解释: http://blogs.msdn.com/b/unnir/archive/2009/03/31/blend-wpf-and-resource-references.aspx

有人在同一个错误的早期SO问题中发布了此链接,但由于某种原因,它没有获得赞誉,并在其他答案下方迷失了方向.

Someone posted this link in an earlier SO question on the same bug, but for some reason it got no upvotes and was lost below other answers.

这篇关于使用资源进行主题化而无需混合呕吐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆