开发者

Numeric edit field in WPF?

开发者 https://www.devze.com 2023-03-19 16:11 出处:网络
Is an edit field that accept only numeric value (for example, to edit numeric parameters) supported natively (using .NET libraries)?

Is an edit field that accept only numeric value (for example, to edit numeric parameters) supported natively (using .NET libraries)?

It's weird t开发者_JAVA百科hat one has to use third party tools for this simple functionality


No, but the WPF Toolkit includes one.

IntegerUpDown http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=wpftoolkit&DownloadId=222922


Not directly. You have a few options though:

  • use the Extended WPF toolkit, it has some already prepackagaed for you (and it's FREE)
  • extend the TextBox control and override the OnPreviewKeyDown function to intercept keypresses you are not interested in


another way to achieve your numeric TextBox is to create a AttachedProperty or Behavior. there are a lot of sample code around.

i create a maskedTextBox behavior for specific input. maybe this can put you in the right direction.

0

精彩评论

暂无评论...
验证码 换一张
取 消