Numeric edit field in WPF?
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.
精彩评论