Numeric Data Entry in WPF

前端 未结 17 2585
情话喂你
情话喂你 2020-12-02 05:38

How are you handling the entry of numeric values in WPF applications?

Without a NumericUpDown control, I\'ve been using a TextBox and handling its PreviewKeyDown eve

17条回答
  •  感动是毒
    2020-12-02 05:47

    Can you not just use something like the following?

    int numericValue = 0;
    
    if (false == int.TryParse(yourInput, out numericValue))
    {
        // handle non-numeric input
    }
    

提交回复
热议问题