把ResourceDictionary保存为文件 Uri skinDictUri = new Uri(".\\Resources\\Skins\\skin.xaml", UriKind.Relative);ResourceDictionary skinDict = Application.LoadComponent(skinDictionaryUri) as ResourceDictionary;XmlWriter xmlWriter = XmlWriter.Create("c:\\a.xaml"); XamlWriter.Save(Application.LoadComponent(skinDictionaryUri), xmlWriter);xmlWriter.Close(); 从外部xaml文件加载ResourceDictionary ResourceDictionary skinDict = new ResourceDictionary();XmlTextReader txtReader = new XmlTextReader("c:\\a.xaml");XmlReaderSettings settings = new XmlReaderSettings();XmlReader xmlReader = XmlReader.Create(txtReader, settings);skinDict = (ResourceDictionary)XamlReader.Load(xmlReader); 相关文章: