样式不更新样式

由网友(关机,重启,从而忘掉你)分享简介:我想在我的应用程序中使用主题化,但我有我的风格不被正确应用的问题。我跑了code以下行:I am trying to use theming within my application, but I am having a problem with my styling not being applied corre...

我想在我的应用程序中使用主题化,但我有我的风格不被正确应用的问题。我跑了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());
阅读全文

相关推荐

最新文章