how to get string value entered in numericupdown silverlight control?

主宰稳场 提交于 2019-12-02 10:54:30

问题


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

Maximum limit 28 and minimum limit is -28

Increment steps are 0.25

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

1,2 and converts it in to 1.2

3,5 and converts it in to 3.5

10,3 and converts it in to 10.3

27,5 and converts it in to 27.5

Now my issue is that when try to enter value

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

How do I achieve it?

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

so I can act on string as I want?

I tried using event

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

        }

but does not help me lot.

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.


回答1:


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.
  } 
}


来源:https://stackoverflow.com/questions/7039529/how-to-get-string-value-entered-in-numericupdown-silverlight-control

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