Styles Don't Update

怎甘沉沦 提交于 2019-12-11 06:55:32

问题


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 );

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

Thanks! Blake


回答1:


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.

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());


来源:https://stackoverflow.com/questions/2699982/styles-dont-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!