首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从IsolatedStorage加载ResourceDictionary

从IsolatedStorage加载ResourceDictionary
EN

Stack Overflow用户
提问于 2012-01-07 06:32:34
回答 2查看 399关注 0票数 0

我正尝试从我的the服务下载一个文件‘teme.xaml’,并将其添加到App.Current.Resources.MergedDictionaries。我遇到的问题是,我不知道如何从IsolatedStorage中的文件创建ResourceDictionary,因为我正在缓存它。

我想做这样的事情:

代码语言:javascript
复制
        ResourceDictionary rd = new ResourceDictionary();
        rd.Source = new (Uri("isostore:/theme.xaml"));
        App.Current.Resources.MergedDictionaries.Clear();
        App.Current.Resources.MergedDictionaries.Add(rd);

但是我在设置信号源的调用中得到一个“未指明的错误”。我非常确定我不能以这种方式处理Uri中的孤立存储。但是,什么才是正确的方法呢?

EN

回答 2

Stack Overflow用户

发布于 2012-01-07 07:07:39

我认为您的代码应该更像是还需要查看配置xml是什么样子的代码

代码语言:javascript
复制
 ResourceDictionary rd = new ResourceDictionary();
 rd.Source = new Uri("/isostore;/theme.xaml", UriKind.RelativeOrAbsolute);
 App.Current.Resources.MergedDictionaries.Clear();
 App.Current.Resources.MergedDictionaries.Add(rd);
票数 0
EN

Stack Overflow用户

发布于 2012-01-19 23:10:59

代码语言:javascript
复制
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()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8765348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档