Ever tried to bind a double value to a textbox in a non-English application? The
number gets formatted in US English style, though you need something totally
different: typically a decimal comma in place of a decimal point.
When searching the web for solutions, you may find such strange ideas like a custom value converter. Using string properties in your view model could also help.
Others will tell you that you have to localize your application.
How to do it correctly
idea shows the correct way – but you do need not follow it completely. While a
thread inherits its language (i.e.,
Windows, some WPF components do not. A single line of code helps (use it e.g.
go a step further. On your non-English Windows, you want to show data in
American style. For that purpose, add a key to the application settings in the
<add key ="UILanguage" value="en-US"/>
Now set the
CurrentUICulture to your value, and also replace
CultureInfo.CurrentCulture.IetfLanguageTag with your value.
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(uiLanguage);
DateTime values are now shown correctly in
TextBoxes. But the
in your Windows settings. Add one more line, and set the
CurrentCulture also. Now it works!
The sample project provides you with a small demo to play with.
Why is WPF so much more complicated than Windows Forms?