样式不更新 [英] Styles Don't Update

查看:153
本文介绍了样式不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中使用主题化,但我有我的风格不被正确应用的问题。我跑了code以下行:

I am trying to use theming within my application, but I am having a problem with my styling not being applied correctly. I run the following lines of code:

        App.Current.Resources.MergedDictionaries.Clear();                       
        ResourceDictionary rd = new ResourceDictionary();
        rd.Source = new Uri( "/Style2.xaml", UriKind.RelativeOrAbsolute );
        App.Current.Resources.MergedDictionaries.Add( rd );

我需要刷新页面?如果是这样,我怎么做,在Silverlight?

Do I need to refresh the page? If so, how do I do that in Silverlight?

谢谢! 布雷克

推荐答案

是的,你需要刷新页面静态资源顾名思义静态的。在XAML分析器解析它们的飞行,因为它是。

Yes you need to "Refresh the page" static resources are as the name suggests static. The Xaml parser resolves them on the fly as it were.

您需要创建一个新的实例不管它是当前已分配给 App.RootVisu​​al 并重新分配给它。下面是一些一般性的code,可能做的伎俩: -

You will need to create a new instance of whatever it is you currently have assigned to the App.RootVisual and re-assign it. Here is some general code that might do the trick:-

  App.RootVisual = (UIElement)Activator.CreateInstance(App.RootVisual.GetType());

这篇关于样式不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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