1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
bool bExit = false;
var dico = new ResourceDictionary();
switch (Thread.CurrentThread.CurrentCulture.ToString())
{
case "en-US":
dico.Source = new Uri("StringResources.xaml", UriKind.Relative);
break;
case "fr-CA":
dico.Source = new Uri("StringResource.fr-CA.xaml", UriKind.Relative);
break;
default:
dico.Source = new Uri("StringResources.xaml", UriKind.Relative);
break;
}
foreach (var sSource in new string[] { "StringResources.xaml", "StringResource.fr-CA.xaml", "StringResources.xaml"})
{
foreach (var resDico in Resources.MergedDictionaries)
{
if (resDico.Source.ToString() == sSource)
{
Resources.MergedDictionaries.Remove(resDico);
bExit = true;
break;
}
}
if (bExit) { break; }
}
Resources.MergedDictionaries.Add(dico);
} |