如何在Silverlight中的NumericUpDown控制得到输入的字符串值? [英] how to get string value entered in numericupdown silverlight control?

查看:450
本文介绍了如何在Silverlight中的NumericUpDown控制得到输入的字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的银色光数字上下控制。控制设置为十进制数。

I am using silver-light numeric up-down control. Control is set for decimal numbers.

上限28和最小限制为-28

增量步骤是0.25

使用荷兰文化这个控制,它的形式接受值

using this control in dutch culture so it accept value in the form

1,2-并将其转换到1.2

1,2 and converts it in to 1.2

3,5,并将其转换到3.5

3,5 and converts it in to 3.5

10, 3,并在将其转换为10.3

10,3 and converts it in to 10.3

27.5,并将其转换到27.5

27,5 and converts it in to 27.5

现在我的问题是,当尝试输入值

Now my issue is that when try to enter value

1.2它转换成12,00(我想应该1.2反映1,2

1.2 it converts it into 12,00 (I want 1.2 should reflect to 1,2)

我该如何实现呢?

或我如何才能在NumericUpDown控件作为字符串输入的字符串值。

or How do I get string value entered in the NumeriCupDown control as string.

这样我就可以字符串作为我想要的吗?

so I can act on string as I want?

我尝试使用事件

private void NumericUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

        }

但并不能帮助我很多东西。

but does not help me lot.

请附上图片凡。非公共成员我得到文本属性NumericUpDown控件,但不能够实现,在我的代码我如何获得该文本属性。

Please find attached image where in Non Public member i am getting Text Property of NumericUpDown control but not able to implement that in my code how do i Get that TEXT property.

推荐答案

创建的NumericUpDown的子类并覆盖ParseValue方式:

Create a subclass of NumericUpDown and override the ParseValue method:

public class MyNumericUpDown : NumericUpDown {

  protected override double ParseValue(string text)
  {
     // Change text to whatever you want
     string newText = FixText(text);

     // Call base implementation.
     base.ParseValue(newText);
  }

  private static string FixText(string inputText) {
    // DO YOUR STUFF HERE.
  } 
}

这篇关于如何在Silverlight中的NumericUpDown控制得到输入的字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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