【发布时间】:2018-04-24 12:20:35
【问题描述】:
如何在自定义资源文件 (resw) 上读取/写入键/值(存储字符串和条件资源)?
我添加了用于存储应用程序设置的资源文件(resw)。然后呢?
private void button1_Click(object sender, RoutedEventArgs e)
{
ResourceContext resourceContext = ResourceContext.GetForViewIndependentUse();
ResourceMap resourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");//resources.resw accessing in root is ok.
var resourceValue = resourceMap.GetValue("PicPath", resourceContext);
resourceMap.SetValue("DBPath", resourceContext,"PicPath2");//no write avaible ? ERROR LINE
}
【问题讨论】:
-
设置?您使用 ResourceLoader,MSDN article 中有很好的描述。
-
没有可用的设定值?资源文件是只读的吗?
-
这两行有什么区别?:ResourceContext resourceContext = ResourceContext.GetForViewIndependentUse();和 ResourceContext resourceContext =new ResourceContext();
标签: uwp raspberry-pi3 uwp-xaml windows-10-iot-core resource-file