标签:
如图:Resource Dictionary (WPF)

这里以英语为默认语言,新建一个 Resource Dictionary (WPF)文件,并命名为DefaultLanguage.xaml,内容如下:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"><!--这行新增加的-->
<sys:String x:Key="OK">
OK
</sys:String>
<sys:String x:Key="Cancel">
Cancel
</sys:String>
</ResourceDictionary>
默认语言文件的 BuildAction要设置为 Page,如图:

为了便于管理,一般将所有的语言文件都放在一个目录下,这里创建lang目录,
然后在创建另一个语言文件,这里是中文,命名为 zh_CN.xaml,内容如下:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="OK">
确定
</sys:String>
<sys:String x:Key="Cancel">
取消
</sys:String>
</ResourceDictionary>
其他非默认语言的设置应该如下:
BuildAction设置为:Content ;CopyToOutputDirectory设置为:Copy if newer (先这样做吧,原因未清)

标签:
原文地址:http://www.cnblogs.com/tommy-huang/p/4613916.html