Silverlight中的动态主题4 [英] Dynamic Themes in Silverlight 4

查看:53
本文介绍了Silverlight中的动态主题4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的App.xaml有这个。 


< ResourceDictionary> 
< ResourceDictionary.MergedDictionaries>
< ResourceDictionary Source =" Themes / RedTheme.xaml" />
< ResourceDictionary Source =" Themes / BlueTheme.xaml" />
< ResourceDictionary Source =" Themes / GreenTheme.xaml" />
< /ResourceDictionary.MergedDictionaries>
< / ResourceDictionary>


 


目前最后输入的内容(greenTheme)将是隐含的主题。有没有人知道我在运行时动态更改这些主题的方法。

解决方案

不支持动态资源查找(WPF的东西)有,但Silverlight没有),这不是直截了当的。


你需要做的是在运行时从代码合并必要的主题,然后刷新XAML内容到如果您希望在用户切换到其他主题时更新UI,请选择新合并的资源。


谢谢,

Unni


My App.xaml has this. 

<ResourceDictionary>
   <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="Themes/RedTheme.xaml"/>
       <ResourceDictionary Source="Themes/BlueTheme.xaml"/>
       <ResourceDictionary Source="Themes/GreenTheme.xaml"/>
   </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

 

At the moment whatever is entered last(greenTheme) will be the implicit theme. Does anyone know a way for me to dynamically change between these themes at runtime.

解决方案

Without support for dynamic resource lookups (something that WPF has, but Silverlight does not), this is not going to be straightforward.

What you would need to do is to merge the necessary themes from code at runtime and then refresh the XAML content to pickup the newly merged in resources if you wanted the UI to update when the user switched to a different theme.

Thanks,
Unni


这篇关于Silverlight中的动态主题4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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