随笔 - 41  文章 - 0  评论 - 24 
  2009年3月4日

把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 @ 2009-03-04 15:45 pdfw 阅读(740) 评论(0) 编辑