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

 

posted on 2009-03-04 15:45  pdfw  阅读(1735)  评论(0编辑  收藏  举报