Allowing users to customize theme colors

I have a windows 8.1 XAML application. I want to allow users to customize the theme of the app themselves - for example, I want to give them a color picker where they can set various colors in the app, which would set various resources used across my app.

The issue though, is I cant find out how to dynamically change the value of a resource. I know in 8.1 they added the concept of a theme resource, which allows me to change from light to dark theme at runtime and what not. But my issue is that I'd like to say 'the backgroundColor resource is now going to be orange, and all items using this resource will reflect this change'

I believe the DynamicResource XAML element is what I needed, but that seems to be from WPF and not supported in Win8. Does anyone have suggestions?

In short - I want to be able to easily provide dynamic resource brushes.


Unfortunately I do not believe that there is a nice built in way of doing this so any solution is likely to be a little bit hacky or unpleasant.

This question has some good answers of which this answer is my personal favourite. The downside is that it results in the ViewModel taking on a bit more responsibility for the view than is ideal.


实际上,您可以动态访问您希望在用户选择时更改的元素的属性。

链接地址: http://www.djcxy.com/p/68014.html

上一篇: 如何定义自己的Windows 8应用主题?

下一篇: 允许用户自定义主题颜色