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

 

posted @ 2022-05-25 16:43  吃葡萄不吐葡萄脾  阅读(267)  评论(0编辑  收藏  举报