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. 配置IIS Express 7.5以允许外部访问

    默认配置文件位于:[我的文档]\IISExpress\config\applicationhost.config修改站点地址如:<binding protocol="http" ...

  2. JVM系列一:JVM内存组成及分配

    java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时 ...

  3. Terrain & Light & Camera

    [Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center o ...

  4. How to run a terminal inside of vim?

    [How to run a terminal inside of vim?] :sh turn vim into shell mode d+trl back to vim 参考:http://stac ...

  5. 帮你选处理器:CPU T9500-p9500-T9400-T9300-p8700对比分析!

    许多人对处理器是P和T开头含混不清,不甚了解,也怪英特尔的处理器型号实在是太过复杂.这需要具体型号来看的.让我们先来看看英特尔的官方解释吧 T: Mobile Highly Performance-- ...

  6. Spring Boot 所提供的配置优先级顺序

    按照优先级从高到低的顺序,具体的列表如下所示. 命令行参数. 通过 System.getProperties() 获取的 Java 系统参数. 操作系统环境变量. 从 java:comp/env 得到 ...

  7. HDU 4493 Tutor (控制精度)

    题意:给定12个数,求平均数. 析:这个题就是精度控制问题,如果控制精度,最好的办法就是用整型了. 代码如下: #include <cstdio> #include <string& ...

  8. Spring MVC体系结构

    [Spring MVC类图]<Spring实战>中:<Spring3.0就这么简单>中:[http://blog.csdn.net/gstormspire/article/de ...

  9. fastJson泛型如何转换

    引子 现在负责的业务 和 json 打交道比较多, 最近使用fastJson框架 json串转成泛型对象遇到了一个异常 : java.lang.ClassCastException 还原下场景 : 模 ...

  10. JS判断是否为安卓orIOS

    var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.indexOf('Android') > - ...