WPF 通过代码添加资源
/// <summary> /// 添加资源到程序环境中 /// /Library.Name;component/Themes/{0}Theme.xaml /// </summary> /// <param name="path">资源路径</param> public static void UpdateResource(string path) { var uri = new Uri(path, UriKind.Relative); ResourceDictionary resources = (ResourceDictionary)Application.LoadComponent(uri); Application.Current.Resources.MergedDictionaries.Add(resources); }