如何完全控制(读/写)自定义资源resw文件(通用Windows) [英] How to Full Control (Read/Write) of custom resource resw file (Universal Windows)

查看:174
本文介绍了如何完全控制(读/写)自定义资源resw文件(通用Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在自定义资源文件(resw)上读取/写入键/值(存储字符串和条件资源)?

How can I read/write Keys/Values on a custom Resource File (resw) (storing string and conditional resources) ?

我添加了用于存储应用程序设置的资源文件(resw).然后呢?

I added Resource File(resw) for storing settings of app. And Then ?

 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
    }

推荐答案

要存储读取/写入应用程序的值,应使用 ApplicationData API .您可以具有本地和/或漫游设置.

To store read / write app values, you should use the ApplicationData API. You can have local and / or roaming settings.

资源是只读的,用于在运行时加载的UI字符串,图像等内容,并且可能需要根据用户的语言,可访问性设置,显示器的比例因子等进行更改.

Resources are read-only and are for things like UI strings, images, etc. that you load at runtime and might want to change based on things like the user's language, the accessibility settings, the display's scale factor, etc.

这篇关于如何完全控制(读/写)自定义资源resw文件(通用Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆