Silverlight 换肤的实现

silverlight 换肤的主要原理是更改APP.xaml中的样式,来更改控件样式。

不同的皮肤可以放在不同的资源文件中。

主要实现代码如下:

  
//ThemePath 为资源文件的路径

public static  void ApplyTheme(string  ThemePath)
        {
            Application.Current.Resources.MergedDictionaries.Clear();
            ResourceDictionary resource = new ResourceDictionary();
            resource.Source = new Uri(ThemePath , UriKind.RelativeOrAbsolute);
            Application.Current.Resources.MergedDictionaries.Add(resource);

        }

  

原文地址:https://www.cnblogs.com/zhangxin1989/p/2816080.html