private void ApplyMultiLanguageResource()
{
ApplyMultiLanguageResource(CultureInfo.CurrentCulture);
}
private void ApplyMultiLanguageResource(CultureInfo cultureInfo)
{
var cultureName = cultureInfo.Name;
var resourceFile = string.Empty;
try
{
resourceFile = @"StringResources." + cultureName + ".xaml ";
}
catch (Exception)
{
}
if (string.IsNullOrEmpty(resourceFile))
resourceFile = @"StringResources.xaml";
var rd = Application.LoadComponent(new Uri(resourceFile, UriKind.Relative)) as ResourceDictionary;
var existsRD = this.Resources.MergedDictionaries.Where(item => item.Source.OriginalString.Equals(resourceFile, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
if (existsRD != null)
this.Resources.MergedDictionaries.Remove(existsRD);
this.Resources.MergedDictionaries.Add(rd);
}
}</pre></div>