WPF application with different CurrentCulture and CurrentUICulture

677 views Asked by At

Our goal is to offer to user setting up different application language and formatting (e.g. texts in English but Date/Number formats in German). So far I have tried different ways and most promising is this one (of course simplified hardcoded version):

var german = new CultureInfo("de-DE");
var english = new CultureInfo("en-US");

Thread.CurrentThread.CurrentCulture = german;
CultureInfo.DefaultThreadCurrentCulture = german;

Thread.CurrentThread.CurrentUICulture = english;
CultureInfo.DefaultThreadCurrentUICulture = english;
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(english.IetfLanguageTag)));

Unfortunately the last line enforce also English formatting for dates and numbers(not just for text). And there is no "CultureProperty" in FrameworkElement to override. So is there a way how to achieve desired behavior without using StringFormat everywhere?

When I try to use german culture for the last line instead of english, then some of the texts are in german instead of english (which is again not correct).

1

There are 1 answers

2
Malitha Shan On