我已经使用MergedDictionaries和项目的设置在我的项目中编写了一个选择语言选项。问题是语言只在我的主窗口和中成功更改,而其他Windows也不成功。我究竟做错了什么?在主窗口
设置语言FUNC(编辑:MainWindow.cs):WPF - 仅在MainWindow中更改语言?
/*set language*/
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
if (Properties.Settings.Default.Language.Equals("en")) //english was set
{
dict.Source = new Uri("\\res\\enDictionary.xaml", UriKind.Relative);
}
else //otherwise - hebrew as default lang.
{
dict.Source = new Uri("\\res\\hebDictionary.xaml", UriKind.Relative);
}
//add required dictionary to the MergedDictionaries
Resources.MergedDictionaries.Add(dict);
}
其中的一个词典[它们设置对称,如果它的事项]的一个小例子:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UI_WPF"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="employees">Employees</system:String>
<system:String x:Key="employers">Employers</system:String>
<system:String x:Key="contracts">Contracts</system:String> </ResourceDictionary>
没有足够的信息,如果字典不添加其无法使用它。这意味着你正在合并导致这个问题的英文字典。 –