Windows 应用商店应用程序中的动态资源? [英] DynamicResource in Windows Store App apps?
问题描述
WPF 对 DynamicResource 的支持非常好,因为这允许用户更改正在运行的应用程序的外观.
WPF's support for DynamicResource is great because this allows users to change the look and fell of a running application.
WinRT 不支持 DynamicResource.
WinRT does not support DynamicResource though.
编写允许用户动态更改 UI 主题的应用程序的推荐方法是什么?
What's the recommended way to write a app which allows users to dynamically change the UI theme?
推荐答案
您并不总是需要动态资源.像这样更改静态"资源的值:
You don't always need a dynamic resource. Change the value of a "static" resource like this:
Resources.Remove("foo");
Resources.Add("foo", "A new hope");
这并不总是适用于声明性的东西.在这些情况下,您可以做的是提供一个包装对象;您无法替换包装器,但可以更新其属性.唉,有些情况下这是不可行的.
This doesn't always work for declarative stuff. What you can do in these cases is provide a wrapper object; you can't replace the wrapper but you can update its properties. Alas there are cases for which this is not viable.
这篇关于Windows 应用商店应用程序中的动态资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!