zoukankan      html  css  js  c++  java
  • WPF 中使用 Resource 实现多语言

    1.在解决方案项目文件夹下面找到Propertys,下边有一个Resources.resx 文件,可以在此定义界面文字。注意,要修改一下资源文件的 Custom Tool property 为PublicResXFileCodeGenerator (原为:ResXFileCodeGenerator)

    2.如果要多语言,复制上边的Resource.resx .然后修改一下文件名为:Resource.zh-CN.resx

    3.如果要在XAML中使用,先引用命名空间:xmlns:Property="clr-namespace:SimilarFinder.Properties",然后在页面上使用下边的方法调用:Text="{x:Static Property:Resources.ApplicationName}"

    4.如果要在CS代码中调用:this.Title = SimilarFinder.Properties.Resources.ApplicationName;

    5.如果要测试不同的语言环境:

    CultureInfo culture = CultureInfo.CreateSpecificCulture("zh-CN");
    Thread.CurrentThread.CurrentCulture = culture;
    Thread.CurrentThread.CurrentUICulture = culture;

  • 相关阅读:
    work 2
    chapter02
    7.23作业
    第五章
    三层交换机
    基于nginx结合openssl实现https
    chapter10--进程和计划任务管理
    Linux系统管理08--服务器RAID及配置实战
    chapter07-- LVM逻辑卷
    Linux系统管理07--文件系统与LVM
  • 原文地址:https://www.cnblogs.com/littleebeer/p/3447933.html
Copyright © 2011-2022 走看看