How to do MVVM Light data binding in non english cultures?
I cannot get data binding in MVVM light to work with numbers for non english cultures. The view model has a decimal property and I want the bound input textbox to handle validation and input according to the curren开发者_开发百科t culture.
Is that not supported or is there an easy work around?
The default culture for WPF UI Elements is en-us. If you want to change this, this might help:
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(
someCulture.IetfLanguageTag)));
Where someCulture
is the culture you want to use for your UI (CultureInfo.CurrentCulture
for the current one). You should call this in Application.Startup
, before any UI elements get created.
精彩评论