WPF用Resource.resX中的字符串进行国际化

增加命名空间

xmlns:prop="clr-namespace:XXAppName.Properties"

引用的地方的格式如下:

<Button x:Uid="testButtonId" Content="{x:Static prop:Resources.Please}" />

在ResX文件中有一个词条叫Please,

在设计器中可以看到,按钮的文字已经变成对应的词条了,但是运行时会发生

Provide value on 'System.Windows.Markup.StaticExtension' threw an exception.'

放狗搜到微软的方法:

I believe your resources are generated as an internal class. WPF is trying to resolve resource from another assembly so it wont succeed until your resources are marked as public. Consider using PublicResXFileCodeGenerator tool introduced in Visual Studio 2008.

在Solution Exploer里选中Resources.resX 在下面的自定义工具里把

ResXFileCodeGenerator改为

PublicResXFileCodeGenerator

选中Resources.resX 点运行自定义工具

重新编译,运行,问题解决。

Localizing WPF with .resx files的更多相关文章

  1. WPF: 本地化(Localization) 实现

    本文将讨论一种较为方便的本地化方法. 由于在项目中要实现本地化,所以在网上查找相关的解决方案.通过一系列调研,发现实现本地化的方法主要有以下三种: 通过编译项目以设置 x:Uid 并使用 LocBam ...

  2. Infralution.Localization.Wpf

    WPF Localization Using RESX Files Once you have downloaded the source code and built it, add a refer ...

  3. 缓动公式整理(附:C#实现及WPF原版对比)

    前言 缓动在动画效果中应用非常广泛,在合适的时候使用一些缓动效果会使得效果更加符合人的直观感受,简单来说,会显得更加自然. WPF提供了11种缓动效果,涵盖了大部分的使用场景.不过如果需要在非WPF下 ...

  4. Code Project精彩系列(转)

    Code Project精彩系列(转)   Code Project精彩系列(转)   Applications Crafting a C# forms Editor From scratch htt ...

  5. Sharepoint学习笔记—习题系列--70-573习题解析 -(Q144-Q146)

    Question 144You are developing a Feature that will be used in multiple languages.You need to ensure ...

  6. C++: read SQL server data using System::Data::SqlClient

    stdafx.h: // stdafx.h : include file for standard system include files, // or project specific inclu ...

  7. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q56-Q58)

    Question 56You work for a manufacturer who needs to advertise its catalog of products online using a ...

  8. Visual Studio - File Properties (Build Action, Copy to Output Directory)

    Ref: MSDN (https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/0c6xyb ...

  9. Add Languages to Your Xamarin Apps with Multilingual App Toolkit

    With Xamarin, you can extend your cross-platform apps with support for native speakers, reaching mar ...

随机推荐

  1. spring MVC 如何查找URL对应的处理类

    在spring 3.1之前,查找URL相应的处理方法,需要分两步,第一步是调用DefaultAnnotationHandlerMapping,查找到相应的controller类,第二步,再调用Anno ...

  2. winform 映射字段的写法:

    public partial class FrmFieldMapping : DevComponents.DotNetBar.Office2007Form { private AMDataFieldC ...

  3. IIS 7 WAS服务不可用

    在 Windows Server 2008 上使用 %windir%\system32\inetsrv\appcmd.exe list wp 命令,得到如下错误: ERROR ( message:WA ...

  4. hdu 3397 Sequence operation(很有意思的线段树题)

    Sequence operation Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. erlang web socket参考。

    出自: http://blog.sina.com.cn/s/blog_96b8a15401010g71.html

  6. Ext.form.ComboBox 后台取值 动态加载 ext5.0.0

    我用的extjs是5.0.0版本的. 请注意:如果这里没有的combobox相关内容,这里一定有. 开始的时候keyup事件取到的数据就是放不到ComboBox中,放全局变量也不好用.最后大神出手帮忙 ...

  7. 批量更改数据库COLLATION

    企业内部有很多系统是繁体的,由于各方面的原因,公司目前正在实行简体化,但各系统中又有数据间的交换,所以系统只能一个一个的更改,以防同时出现过多的问题.由于原先数据库只能存储繁体,而原先已存在的数据则可 ...

  8. Hadoop ecosystem

    How did it all start- huge data on the web! Nutch built to crawl this web data Huge data had to save ...

  9. Synchronization in Delphi TThread class : Synchronize, Queue

    http://embarcadero.newsgroups.archived.at/public.delphi.rtl/201112/1112035763.html > Hi,>> ...

  10. uva208 - Firetruck

    Firetruck The Center City fire department collaborates with the transportation department to maintai ...