New to Telerik UI for WinUI? Download free 30-day trial

Key Properties

This article lists the key properties of the RadMaskedInput control.

Mask and MaskType

The Mask property is a string of characters that constrain user input. The Mask property may contain literals and special mask characters. The MaskType determines how the mask characters are interpreted. Learn more about the different mask types in the Mask Types section.

Use the backslash "\" character to escape any mask characters so that they display as literals. At runtime, any blank space occupied by a Mask character is displayed as the PromptChar property character.

Value, Text and ValueFormat

The Value property returns user input without the formatting characters. If you want the input and the formatting characters, use the Text property instead.

If you want to allow the value to hold also literals and prompt characters, you can enable this by setting the ValueFormat property of the control.

Header, HeaderTemplate and Description

Similarly to other controls, the RadMaskedInput exposes the Header and HeaderTemplate properties which allow you to display a header on top of the control and also specify a DataTemplate for it in which you can create a more complicated layout.

In addition, you can also define a Description which will be displayed beneath the control.

Example 1: Setting the Header, HeaderTemplate and Description

<telerik:RadMaskedInput Mask="###" Header="Header" Description="Description of this input"> 
    <telerik:RadMaskedInput.HeaderTemplate> 
        <DataTemplate> 
            <StackPanel Orientation="Horizontal"> 
                <Ellipse Fill="Red" Width="10" Height="10" Margin="5" /> 
                <TextBlock Text="{Binding}" /> 
            </StackPanel> 
        </DataTemplate> 
    </telerik:RadMaskedInput.HeaderTemplate> 
</telerik:RadMaskedInput> 
Header, HeaderTemplate and Description

Empty Text

the EmptyText property determines the text that will be displayed, when the Value of the control is null.

Example 2: Setting the EmptyText property

<telerik:RadMaskedInput Mask="####" EmptyText="Please Enter Four Digits" /> 
Setting the EmptyText property

Allow Null Values

By default the RadMaskedInput doesn't allow you to set null as its Value property. Instead the null value is coerced to 0. To alter this behavior and allow null values you can set the AllowNullValue property to True.

Example 3: Setting AllowNullValue property

<telerik:RadMaskedInput AllowNullValue="True" /> 

Allow Invalid Values

The RadMaskedInput control will update its Value property only when its input passes the validation process. The validation rules are determined by the symbols set in the Mask property. Otherwise, the ValueChanged event won't be triggered. To allow property change on every user input, you can set the AllowInvalidValues property to True.

Example 4: Allow Invalid Values

<telerik:RadMaskedInput Mask="AAAAAA" AllowInvalidValues="True" /> 

Allow Prompt as Input

Via the AllowPromptAsInput property you can control whether the prompt character should be treated as a valid input character or not.

Please note that even when AllowPromptAsInput is True, the prompt character must be valid for the current location in the mask in order to be accepted. For example, if PromptChar is "*", and the current location in the mask demands the user enter a digit, entering an asterisk (*) will fail.

Restrict to ASCII

The RestrictToAscii property allows you to restrict input to ASCII-compatible characters if you do not wish to allow the entire Unicode set.

Culture

The RadMaskedInput control provides full globalization support out-of-the-box through the Culture property. Read more about this in the Culture article.

IsReadOnly

The IsReadOnly property determines if the user can change the text in the control.

See Also

In this article
Not finding the help you need?