本文介绍一种WPF程序实现本地化的方法。

步骤

首先,假设xaml文件中存在一个Button按钮,内容为“按钮”,实现本地化的步骤如下:

  1. 展开程序的Properties,双击Resources.resx文件进行编辑;
  2. 添加一条资源,名称为"btnContent",值为"按钮";
  3. 右键复制Resources.resx然后粘贴,改名为Resources.en-US.resx;
  4. 添加资源,名称为"btnContent",值为"button";
  5. 在需要使用该资源的xaml文件中,引入Properties名称空间:
xmlns:prop="clr-namespace:WpfApplication1.Properties"
  1. 使用方法:
<Button Content="{x:Static prop:Resources.btnContent}"/>
  1. 测试:
protected override void OnStartup(System.Windows.StartupEventArgs e)
{
base.OnStartup(e);
// 注释掉该行会显示汉语,否则会显示英语
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("en-US");
}

WPF -- 一种实现本地化的方法的更多相关文章

  1. 解决VS2019中.net core WPF 暂时无法使用 Designer 的临时方法

    目录 解决 VS2019 中.net core WPF 暂时无法使用 Designer 的临时方法 安装 vs 2019 professional/enterprise版本 在vs的设置里,勾选.NE ...

  2. javascript四种类型识别的方法

    × 目录 [1]typeof [2]instanceof [3]constructor[4]toString 前面的话 javascript有复杂的类型系统,类型识别则是基本的功能.javascrip ...

  3. iOS 三种收起键盘的方法

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  4. 干货:结合Scikit-learn介绍几种常用的特征选择方法

    原文  http://dataunion.org/14072.html 主题 特征选择 scikit-learn 作者: Edwin Jarvis 特征选择(排序)对于数据科学家.机器学习从业者来说非 ...

  5. WPF 获取程序路径的一些方法,根据程序路径获取程序集信息

    一.WPF 获取程序路径的一些方法方式一 应用程序域 //获取基目录即当前工作目录 string str_1 = System.AppDomain.CurrentDomain.BaseDirector ...

  6. 【读书笔记】iOS-开发技巧-三种收起键盘的方法

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  7. 结合Scikit-learn介绍几种常用的特征选择方法

    特征选择(排序)对于数据科学家.机器学习从业者来说非常重要.好的特征选择能够提升模型的性能,更能帮助我们理解数据的特点.底层结构,这对进一步改善模型.算法都有着重要作用. 特征选择主要有两个功能: 减 ...

  8. C#两种创建快捷方式的方法

    C#两种创建快捷方式的方法http://www.cnblogs.com/linmilove/archive/2009/06/10/1500989.html

  9. jsp中四种传递参数的方法

    jsp中四种传递参数的方法如下: 1.form表单 2.request.setAttribute();和request.getAttribute(); 3.超链接:<a herf="i ...

随机推荐

  1. HashMap源码(JDK1.8)-手动注释

    HashMap简介 HashMap是一种K-V映射的一种数据结构,通过K(key)值能实现在O(1)的时间复杂度下找到对应的V(value).JDK1.8之前,HashMap的底层数据结构是数组+链表 ...

  2. 设计模式(五)——原型模式(加Spring框架源码分析)

    原型模式 1 克隆羊问题 现在有一只羊 tom,姓名为: tom, 年龄为:1,颜色为:白色,请编写程序创建和 tom 羊 属性完全相同的 10 只羊. 2 传统方式解决克隆羊问题 1) 思路分析(图 ...

  3. P3384 [模板] 树链剖分

    #include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, rt, mod, cnt, to ...

  4. hdu4028 The time of a day (map+dp)

    Problem Description There are no days and nights on byte island, so the residents here can hardly de ...

  5. hdu4339 Query

    Problem Description You are given two strings s1[0..l1], s2[0..l2] and Q - number of queries. Your t ...

  6. XSS脚本汇总

    (1)普通的XSS JavaScript注入<SCRIPT SRC=http://***/XSS/xss.js></SCRIPT> (2)IMG标签XSS使用JavaScrip ...

  7. WebXR All in One

    WebXR All in One VR / WebVR WebXR https://www.w3.org/TR/webxr/ WebXR Device API https://immersiveweb ...

  8. front-end & web & best code editor

    front-end & web & best code editor 2019 VS Code https://designrevision.com/best-code-editor/ ...

  9. shit nuxt.js sensors-data

    shit nuxt.js sensors-data why I can not close it? https://github.com/nuxt/nuxt.js/issues?q=sensors+d ...

  10. github & code owners

    github & code owners https://help.github.com/en/github/creating-cloning-and-archiving-repositori ...