WPF and Silverlight Edition Basic Library / Masked Text Box / Mask Elements / Adding Mask
Adding Mask

You can easily add a mask for currency values using the Mask property. By default the C1MaskedTextBox control starts with its Mask not set but you can customize this at design time, in XAML, and in code. For more details about mask characters, see Mask Elements.

For example, to set the Mask property add Mask="$999,999.00" to the <c1:C1MaskedTextBox> tag so that it appears similar to the following:

XAML
Copy Code
<c1:C1MaskedTextBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="C1MaskedTextBox1" VerticalAlignment="Top" Width="120" Mask="$999,999.00"></c1:C1MaskedTextBox>

 

Run your project and observe:

The mask will appear in the control:

Enter a number; notice that the mask is filled: