本文介绍一种WPF程序实现本地化的方法。ide
首先,假设xaml文件中存在一个Button按钮,内容为“按钮”,实现本地化的步骤以下:测试
xmlns:prop="clr-namespace:WpfApplication1.Properties"
<Button Content="{x:Static prop:Resources.btnContent}"/>
protected override void OnStartup(System.Windows.StartupEventArgs e) { base.OnStartup(e); // 注释掉该行会显示汉语,不然会显示英语 System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); }