我正尝试从我的the服务下载一个文件‘teme.xaml’,并将其添加到App.Current.Resources.MergedDictionaries。我遇到的问题是,我不知道如何从IsolatedStorage中的文件创建ResourceDictionary,因为我正在缓存它。
我想做这样的事情:
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new (Uri("isostore:/theme.xaml"));
App.Current.Resources.MergedDictionaries.Clear();
App.Current.Resources.MergedDictionaries.Add(rd);但是我在设置信号源的调用中得到一个“未指明的错误”。我非常确定我不能以这种方式处理Uri中的孤立存储。但是,什么才是正确的方法呢?
发布于 2012-01-07 07:07:39
我认为您的代码应该更像是还需要查看配置xml是什么样子的代码
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri("/isostore;/theme.xaml", UriKind.RelativeOrAbsolute);
App.Current.Resources.MergedDictionaries.Clear();
App.Current.Resources.MergedDictionaries.Add(rd);发布于 2012-01-19 23:10:59
using (var storage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = new IsolatedStorageFileStream("theme.xaml", FileMode.Open, storage))
{
var xaml = XElement.Load(stream);
}
}如果你能让它起作用,试一试。我已经使用这种方法加载了xmlfile。我认为可以使用Application.GetResourceStream而不是XElement.Load()
https://stackoverflow.com/questions/8765348
复制相似问题