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. 100offer 为专业程序打造的招聘平台

    引用一段100offer的简介 优秀程序员最高效的求职方式 您是名优秀的程序员,很多公司都想邀请您加入,您也有一颗躁动的心.可是,换一份工作对于您,是件机会成本很高的事情.您想一次性看很多个不错的机会 ...

  2. HDU 1079 Calendar Game(简单博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. LightOJ 1282 Leading and Trailing (快数幂 + 数学)

    http://lightoj.com/volume_showproblem.php?problem=1282 Leading and Trailing Time Limit:2000MS     Me ...

  4. ASP.NET的分页方法(四)

    这是我早先得到的一段JS代码,只需要修改一下开头的几个参数,就可以使用,不知道能否试用于静态页面呢,大家可以尝试一下 <script language="javascript" ...

  5. JS鼠标滚动事件

    -----------------------------//鼠标滚动事件以下是JS临听鼠标滚动事件 并且还考虑到了各浏览器的兼容----------------------------------- ...

  6. 全世界最短IE判定if(!+[1,])的解释(转)

    全世界最短IE判定if(!+[1,])的解释   虽然从司徒先生的博客上看到 全世界最短的IE判定 很长时间了,却一直对于原理没怎么去细看,今天同事(也是一后台程序员,并非前端)又问到这个问题,于是我 ...

  7. non-manifold Mesh(非流形网格)

    三角网格曲面中,大多的算法基于流形网格manifold mesh,其定义如下: 1)Each edge is incident to only one or two faces: 一条网格边为一个或两 ...

  8. javascript自执行函数为什么要把windows作为参数传进去

    http://segmentfault.com/q/1010000000311686 (function (window, $, undefined) { play=function(){ $(&qu ...

  9. CloudStack4.2 二级镜像存储测试

    //添加二级存储{ "addimagestoreresponse": { "imagestore": { "id": "2dda4 ...

  10. xmlBean学习一

    在文档中看到了xmlBean的出现,因为项目使用JMS,模块之间通过xml文件传递数据,就学一下xmlBean,java中还提供了DOM,SAX来解析xm,但也是比较麻烦的:而xmlbean则将xml ...