Sunday, August 15, 2010

WPF Value Type Text Box

I wrote a WPF numeric text box control that can support currency, integer and numeric values.
It can prevent invalid input such as letters, spaces, etc. and can be constrained to a max length value.

For example, with the currency text box; when the text box is in focused the formatting is removed allowing the user to enter the value.
When the text box loses focus, formatting is reapplied and display in the text box.

Value Type Text Box

Please let me know if this helps you.


Thinker said...

Wanted to answer generally, I like your blog Huy. Your stuff is always nice and helpfull. I think not many people know your blog :/

Anonymous said...

I've tried this out and one problem I've found is that although you can Tab through it, you cannot Shift-Tab backwards through it (it gets focus correctly, but will not give focus to the previous control as it should do)

It would also benefit from permitting formatted currencies to be pasted in (eg assuming a UK locale, if "£123" was pasted in it should accept it as "123" (and then format is as "£123" on lost focus as normal))

Otherwise nice work, thanks!

Anonymous said...

This saved me a lot of time. Thank you very much.