Localization in Silverlight 4 using ResourceWrapper

Posted by Artur on Stack Overflow See other posts from Stack Overflow or by Artur
Published on 2010-04-28T12:48:02Z Indexed on 2010/04/28 12:53 UTC
Read the original article Hit count: 1019

Filed under:
|
|

I have a business application (created from template) and I can change language dynamically by making ResourceWrapper INotifyPropertyChanged and then adding in code:

private void Language_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
 Thread.CurrentThread.CurrentCulture =
     new CultureInfo(((ComboBoxItem)((ComboBox)sender).SelectedItem).Tag.ToString());
 Thread.CurrentThread.CurrentUICulture =
     new CultureInfo(((ComboBoxItem)((ComboBox)sender).SelectedItem).Tag.ToString());
 ((ResourceWrapper)App.Current.Resources["ResourceWrapper"]).ApplicationStrings =
     new ApplicationStrings();
}

this works fine on resources referenced/binded in xaml files (i.e. MainPage frame), but it does not update references of anything I have declared in code i.e.

InfoLabel.Content = ApplicationStrings.SomeString

At the moment I'm not using ResourceWrapper. My question here is how can I change my code so it uses it and updates when ResourceWrapper change. I tried:

InfoLabel.Content = ((ResourceWrapper)App.Current.Resources["ResourceWrapper"])
    .ApplicationStrings.SomeString

but it doesn't work.

Any ideas?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about localization