WPF文本框绑定到十进制尊重文化 [英] WPF TextBox binding to decimal respecting culture

查看:192
本文介绍了WPF文本框绑定到十进制尊重文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绑定一个TextBox到一个小数。我的问题IST,绑定是使用美国的数量标准,使用小数分离点(1.5)

I've bound a TextBox to a Decimal. My problem ist, the Binding is using american numerical standards, using a dot for decimals separation ("1.5")

我的系统是德国和配置为小数分离使用冒号(1.5)。

My system is german and configured to use a colon as decimals separation ("1,5").

我需要的文本框的结合来显示和使用冒号,而不是一个点分隔小数。

I need the TextBox binding to show and use a colon instead of a dot to separate decimals.

我如何获得绑定到尊重数字输入当前设置的本地化/区域性设置?

How do I get the binding to respect the currently set localization/culture settings for numerical input?

推荐答案

阅读的这篇文章。您应该设置默认语言为所有框架元素:

Read this article. You should set default language for all framework elements:

public partial class App : Application
{
    static App()
    {
        FrameworkElement.LanguageProperty.OverrideMetadata(
            typeof(FrameworkElement),
            new FrameworkPropertyMetadata(
                XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
    }
}

这篇关于WPF文本框绑定到十进制尊重文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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