StringFormat不工作.. [英] StringFormat is not working..

查看:87
本文介绍了StringFormat不工作..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以"### - ## - ####"的格式显示SSN。但它不起作用,它显示纯文本。不确定可能的原因。例如,我想要"123-45-6789",但它显示"123456789"。

I want to display SSN in the format "###-##-####". However it is not working, it display the plain text. Not sure the possible cause. For example, I want "123-45-6789", but it shows "123456789".

<TextBox Text="{Binding SocialSecurityNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat={}{0:"###-##-####"}}" Style="{StaticResource MyStyle}"/>

谢谢。

Thanks.

推荐答案

您好HZ.USA,

Hi HZ.USA,

您可以看看:

  <TextBox
            x:Name="textbox1"
            Height="30"
            Text="{Binding myvalue1, StringFormat={}{0:###-##-####}}" />


  public double myvalue1 { get; set; }

        public Window33()
        {
            InitializeComponent();
            myvalue1 = 123456789;
            this.DataContext = this;
        }

最好的问候,

Cherry


这篇关于StringFormat不工作..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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