UWP在Class Library 类库项目中读取.resw文件中的内容
为了今后方便调用通常需要将公共方法编译成dll等类库形式,下面方法是在类库项目中读取Strings.resw资源文件的内容(可用于实现多语言组件):
1 2 3 4 5 6 |
Windows.ApplicationModel.Resources.Core.ResourceContext resourceContext = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse(); Windows.ApplicationModel.Resources.Core.ResourceMap resourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("【不带路径的文件名不带扩展名】"); // Here you load the resource you need var resourceValue = resourceMap.GetValue("【字段名如图Message】", resourceContext); string valueString = resourceValue.ValueAsString; |
如果您对C#游戏开发感兴趣,可以扫下面二维码加入我们的QQ群来一起学习交流
原创文章,转载请注明本文链接地址(违者必究):UWP在Class Library 类库项目中读取.resw文件中的内容