简体   繁体   中英

How to use resources in XAML from .resources files (not .resx files)?

I have tested a small WPF program where I have specified the GUI text in two different resx-files (Resource1.resx and Resource1.sv-SE.resx). This way I can change the language of the GUI to Swedish or English.

But now I'm trying how to use a .resources file instead of a .resx file (created with ResourceWriter() ).

But I can't get it to work. I have verified with resgen that the .resources file have the correct data.

Any tutorials or info how to do this?

And why do I want to do this? I have been assigned an older project that uses .resources to translate GUI text. And I want to learn how it works with a small project at home :-) But I tested with .resx files first, and that works.

This is how it looks when I get it to work with .resx files:

我的小WPF测试项目

.resources files are not intended to be used in XAML the same way as resx .

Unlike resx, which is readable XML data, .resources is binary. They are to be embedded in a runtime executable or compiled into a satellite assembly.

To read data from .resources file, you need to do it in C# code, by using ResourceReader class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM