I'm seeing strange behavior in a WPF app (which I reproduced in a sample app to be sure).
When the app starts I'm setting CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture to e.g. French, before the main app window loads. Then the main app window loads and localized text appears as expected, in French, like so:
<Window.Resources>
<Strings x:Key="Resources"/>
</Window.Resources
<Button Content={Binding Label, Source={StaticResource Resources}}/>
The problem is that if I click the button, the culture and the button's text gets reset to en-US. I added an event handler for the Click event and inside it CurrentCulture and CurrentUICulture are both reset to "en-US".
Any idea why this happens? It seems weird that this would somehow happen automatically.
Note: I've also tried doing
var cultureName = CultureInfo.CurrentCulture.Name;
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(cultureName)));
and
this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
before the main window loads, but it doesn't help, the culture still gets reset.
UPDATE: I asked the question also on the WPF forums (https://social.msdn.microsoft.com/Forums/vstudio/en-US/884af2cb-fcc3-4cfe-bea0-7a84f74583a8/culture-gets-reset-on-button-click?forum=wpf). There I described the actual scenario maybe a bit better: I need to be able to set a specific culture when the app starts and have it be "preserved" throughout the app's lifetime. Unfortunately when clicking a button the culture gets reset, as described.