Tweets by @Actipro
Please take some time to learn more about us and our product offerings.
Another control we are working on as part of the Editors for WPF product is the MaskedTextBox control. Built from scratch, this control allows user input to be restricted based on a regular expression pattern.
The regular expression supports simple literals and character classes, in addition to quantifiers (*, +, ?, etc) and alternations (a|b). For example, the following regular expression will match a U.S. phone number with or with a preceding area code or 1:
Valid entries for this regular expression include:
By default, the non-option regex elements will be presented using a configurable prompt character or glyph. Additionally, literal characters will be displayed when appropriate and are not required to be entered by the user.
A MaskedTextBox with the regex defined above, with no user input
When "5" is entered three times, the control fills in the three required regex elements and moves the caret over the dash, since it's a literal character and is required.
A MaskedTextBox with the regex defined above, with "555" typed as input
When "(70" is entered, then the left parenthesis indicates that the first entry in the regex alternation must be taken. Therefore, the proceeding "70" are entered in the area code. Additionally, two new literal characters are added, the ")" followed by a space, since they are required for that branch of the alternation.
A MaskedTextBox with the regex defined above, with "(70" typed as input
Finally, when "1-70" is entered, then the "1" would initially be associated with one of the required regex elements outside the alternation. But, when the "1" is followed by a "-" then it must take the second alternation branch, thus allowing "70" to be entered as the area code.
A MaskedTextBox with the regex defined above, with "1-70" typed as input
The prompt indicator can be any printable character, a custom Geometry (as seen above), or can be excluded all together. Additionally, the brush used for the prompt indicator can be defined separately from the foreground brush for the text. This allows the prompt indicator to have a subtle appearance, so it does not distract from the entered text.
By default, any literal characters will automatically be inserted when required. This saves the user from having to needlessly type common characters. It is also possible to require that the literal characters be entered manually. Therefore, the user must type every character in the regular expression into the MaskedTextBox.
The MaskedTextBox will be leveraged by the parts-based editors to help restrict and validate user input. So that things like the year part of DateTime parts-editor, only allows digits. Additional hooks will be available to verify that the "digits" actually equate to a valid year. This hooks will be available for general use, so that restricting and validating input will be a snap.
January 21, 2009 at 20:01
This is just what I am looking for. Any rough idea of when it will be available for current customers?
January 22, 2009 at 03:06
Hi Christopher,We currently are finishing up some of the fundamentals of the framework for the control. Then we will be working on specific implementations using the framework, such as a DateTimePicker, etc. The framework is working out to be very nice and will allow you to create your own flexible implementations as well.Keep an eye on the blog since we'll continue updating it with information as we get closer to release.
Bill Henning (Actipro)
January 23, 2009 at 03:13
I'll have to admit that, while Regular Expression syntax allows for much greater flexibility, it is also less accessible.Any chance that you will also support the syntax of the WinForm MaskedEdit control as well?
January 25, 2009 at 04:37
Hi David,Thanks for the suggestion. We will try to include that in the initial release, but it might have to wait for a follow up release.We could do a direct conversion from the Winform syntax to our regex format, but there are some incompatibilities (specifically dealing with optional values). We would prefer to have our MaskedTextBox work like the WinForms MaskedTextBox, when using the same syntax.
Tom Goff (Actipro)