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

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

  • 相关阅读:
    鼠标移上与移出事件
    最小高度 最大高度
    鼠标移上改变光标
    设置圆角
    iframe 子窗口获取父窗口元素 父窗口获取子窗口元素
    parent
    禁用滚动条
    mysql--user表
    mysql客户端连不上数据库
    linux下安装MySQL
  • 原文地址:https://www.cnblogs.com/jans2002/p/3326437.html
Copyright © 2011-2022 走看看