In WPF, any bindings which don't explicitly specify a culture will use the invariant culture instead. That means you'll get American date and number formats, ignoring your current regional settings.
This is a long-standing problem, which the WPF team considers to be "by design".
The standard workaround is to override the property metadata for the FrameworkElement
's Language
property:
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
This needs to be done before you show any UI - usually in the OnStartup
event.
Unfortunately, this will only solve the problem for elements derived from FrameworkElement
. The Run
element, for example, derives from FrameworkContentElement
, and so it won't be affected by this change. And you can't override the metadata for the FrameworkContentElement
, as it has already been overridden.
Another alternative is to create and use a custom binding which always initializes the culture to CultureInfo.CurrentCulture
:
public class CultureBinding : System.Windows.Data.Binding
{
public CultureBinding(string path) : base(path)
{
ConverterCulture = CultureInfo.CurrentCulture;
}
public CultureBinding()
{
ConverterCulture = CultureInfo.CurrentCulture;
}
}
DateTIme
? Locale settings can affect format. Looks like NA\EU confusion in your case. – icebat