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

        }

  

posted @ 2012-12-13 12:42  程序之魂  阅读(232)  评论(0编辑  收藏  举报