WPF double valued data binding with custom decimal separator

最后都变了- 提交于 2019-12-12 12:32:11

问题


Is there a centralized way to have the WPF UI to respect the customized decimal separator set in Control Panel -> Regional Settings?

When I bind a double valued data to a text box, I want to enter the value using the decimal separator set in Regional settings.

The code below (when put in App's ctor) will use the decimal separator of the current culture settings, but will not respect the customized decimal separator setting. I was hoping that this code could somehow easily be exteded to cover the customized decimal separator as well.

FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
             new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

回答1:


Have you tried using StringFormat in your binding?




回答2:


Perhaps a bit late but I found this when researching my own formating problem.

The name "CultureInfo.UseUserOverride" is pretty self explanatory.



来源:https://stackoverflow.com/questions/5789007/wpf-double-valued-data-binding-with-custom-decimal-separator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!