zoukankan      html  css  js  c++  java
  • Localizing WPF with .resx files

    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 点运行自定义工具

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

  • 相关阅读:
    mysql-数据库增删改查
    判断,循环
    数组
    html 三种垂直居中
    箭头函数
    Array类型
    object
    JAVA WEB 行业技术
    一个好的程序员
    经典语录
  • 原文地址:https://www.cnblogs.com/jans2002/p/3326437.html
Copyright © 2011-2022 走看看