Runtime theme switching with explicit styles in Silverlight 4

倖福魔咒の 提交于 2019-12-05 13:38:44

I'm no longer at the company, so I can't post the specific code we ended up using, but we did go with an attached property approach. We replaced the assignment to the Style property for objects that needed to be dynamically skinned with a Theming.Style attached property set to the same value. Then, in our resource dictionaries, we created styles prefixed with a theme name, for example, where we once had a "StandardButton" style, we would create additional styles with the names "Blue|StandardButton" and "Clean|StandardButton". Our theming engine would then be able to look up those theme-specific styles whenever we switched themes and apply them to the elements with the attached properties.

Hopefully this is a helpful approach to others, but preferably there's a library out there that already solves this problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!