Mask Syntax for the Masked Text Box

The MaskedTextBox uses the standard .NET MaskedTextProvider mask syntax. For full information see the .NET Framework SDK; a summary is provided below.

Mask Character Accepts Required?
0 Digit (0-9) Required
9 Digit (0-9) or space Optional
# Digit (0-9) or space Required
L Letter (a-z, A-Z) Required
? Letter (a-z, A-Z) Optional
& Any character Required
C Any character Optional
A Alphanumeric (0-9, a-z, A-Z) Required
a Alphanumeric (0-9, a-z, A-Z) Optional
. Decimal separator Required
, Group (thousands) separator Required
: Time separator Required
/ Date separator Required
$ Currency symbol Required

In addition, the following characters have special meaning:

Mask Character Meaning
< All subsequent characters are converted to lower case
> All subsequent characters are converted to upper case
| Terminates a previous < or >
\ Escape: treat the next character in the mask as literal text rather than a mask symbol

All other characters are treated as literals.

XAML Considerations

XML reserves the &, < and > are special characters. To use these in a mask string in XAML, encode them as &amp;, &lt; and &gt; respectively.