WPF双值数据绑定与自定义小数分隔符 [英] WPF double valued data binding with custom decimal separator

查看:360
本文介绍了WPF双值数据绑定与自定义小数分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有集中的方式使WPF UI遵守在控制面板 - >区域设置中设置的自定义小数分隔符?

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.

下面的代码(放在App的ctor中)将使用当前文化设置的小数分隔符,但不会遵循自定义的小数分隔符设置。我希望这段代码可以轻而易举地覆盖定制的小数分隔符。

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)));


推荐答案

也许稍晚,但我发现这个在研究我自己的形成问题。

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

名称CultureInfo.UseUserOverride是非常自明的。

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

这篇关于WPF双值数据绑定与自定义小数分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆