Class SfMaskedTextBox
The SfMaskedTextBox control is an enhanced version of a text box that additionally restricts input to conform to a specific structure or mask.
Inheritance
Namespace: Syncfusion.UI.Xaml.Editors
Assembly: Syncfusion.Editors.WinUI.dll
Syntax
public class SfMaskedTextBox : Control
Examples
This example illustrates how to set email mask value using regex mask.
<syncfusion:SfMaskedTextBox Header="Email Input" MaskType="RegEx" Mask="[A-Za-z0-9-.%]+@[A-Za-z0-9]+.[A-Za-z]{3}"/>
SfMaskedTextBox maskedTextBox = new SfMaskedTextBox();
maskedTextBox.MaskType = MaskedTextBoxMaskType.RegEx;
maskedTextBox.Mask = "[A-Za-z0-9-.%]+@[A-Za-z0-9]+.[A-Za-z]{3}";
maskedTextBox.Header = "Email Input";
Constructors
SfMaskedTextBox()
Initializes the new instance of the class.
Declaration
public SfMaskedTextBox()
Fields
CultureProperty
Identifies the Culture dependency property.
Declaration
public static readonly DependencyProperty CultureProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Culture dependency property. |
DescriptionProperty
Identifies the Description dependency property.
Declaration
public static readonly DependencyProperty DescriptionProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Description dependency property. |
HeaderProperty
Identifies the Header dependency property.
Declaration
public static readonly DependencyProperty HeaderProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Header dependency property. |
HeaderTemplateProperty
Identifies the HeaderTemplate dependency property.
Declaration
public static readonly DependencyProperty HeaderTemplateProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the HeaderTemplate dependency property. |
MaskProperty
Identifies the Mask dependency property.
Declaration
public static readonly DependencyProperty MaskProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Mask dependency property. |
MaskTypeProperty
Identifies the MaskType dependency property.
Declaration
public static readonly DependencyProperty MaskTypeProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the MaskType dependency property. |
PromptCharProperty
Identifies the PromptChar dependency property.
Declaration
public static readonly DependencyProperty PromptCharProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the PromptChar dependency property. |
TextProperty
Identifies the Text dependency property.
Declaration
public static readonly DependencyProperty TextProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Text dependency property. |
ValueMaskFormatProperty
Identifies the ValueMaskFormat dependency property.
Declaration
public static readonly DependencyProperty ValueMaskFormatProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the ValueMaskFormat dependency property. |
ValueProperty
Identifies the Value dependency property.
Declaration
public static readonly DependencyProperty ValueProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Value dependency property. |
Properties
Culture
Gets or sets the culture for mask values based on the given Culture.
Declaration
public CultureInfo Culture { get; set; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo | It takes the culture value. The default value is System.Globalization.CultureInfo.CurrentCulture. |
Description
Gets or sets the content for control's description.
Declaration
public object Description { get; set; }
Property Value
Type | Description |
---|---|
System.Object | It takes the object value. The default value is null. |
Examples
<syncfusion:SfMaskedTextBox Description="SfMaskedTextBox"/>
Header
Gets or sets the content for control's header.
Declaration
public object Header { get; set; }
Property Value
Type | Description |
---|---|
System.Object | It takes the object value. The default value is null. |
Examples
<syncfusion:SfMaskedTextBox Header="SfMaskedTextBox"/>
HeaderTemplate
Gets or sets the data template used to display the content of the control's header.
Declaration
public DataTemplate HeaderTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DataTemplate | It takes data template value. The default value is null. |
Examples
<syncfusion:SfMaskedTextBox Header="SfMaskedTextBox">
<syncfusion:SfMaskedTextBox.HeaderTemplate>
<DataTemplate>
<TextBlock Text = "{Binding}" FontWeight="Bold" />
</DataTemplate>
</syncfusion:SfMaskedTextBox.HeaderTemplate>
</syncfusion:SfMaskedTextBox>
Mask
Gets or sets the mask value which restricts the inputs provided in the control.
Declaration
public string Mask { get; set; }
Property Value
Type | Description |
---|---|
System.String | It takes the string value. The default value is null. |
MaskType
Gets or sets the mask type for the SfMaskedTextBox control.
Declaration
public MaskedTextBoxMaskType MaskType { get; set; }
Property Value
Type | Description |
---|---|
MaskedTextBoxMaskType | It takes the mask type value. The default value is Simple. |
Examples
<syncfusion:SfMaskedTextBox MaskType="RegEx" Header="Email Input" Mask="[A-Za-z0-9-.%]+@[A-Za-z0-9]+.[A-Za-z]{3}"/>
PromptChar
Gets or sets a char which used as a prompt char of SfMaskedTextBox.
Declaration
public char PromptChar { get; set; }
Property Value
Type | Description |
---|---|
System.Char | It takes the char value. The default value is "_". |
Text
Gets or sets the displayed text of the SfMaskedTextBox control.
Declaration
public string Text { get; }
Property Value
Type | Description |
---|---|
System.String | It takes the string value. The default value is empty. |
Value
Gets or sets the input value for SfMaskedTextBox control.
Declaration
public object Value { get; set; }
Property Value
Type | Description |
---|---|
System.Object | It takes the value of masked edit. The default value is null. |
Examples
<syncfusion:SfMaskedTextBox MaskType="Simple" Mask="00/00/0000" Value="12"/>
ValueMaskFormat
Gets or sets the format for the value.
Declaration
public MaskedTextBoxMaskFormat ValueMaskFormat { get; set; }
Property Value
Type | Description |
---|---|
MaskedTextBoxMaskFormat | It takes the mask format for the value. The default value is IncludePromptAndLiterals. |
Examples
<syncfusion:SfMaskedTextBox Name="maskedTexBox" Mask="00/00/0000" Value="12" ValueMaskFormat="ExcludePromptAndLiterals"/>
Methods
OnApplyTemplate()
Initializes the child elements.
Declaration
protected override void OnApplyTemplate()
OnPointerEntered(PointerRoutedEventArgs)
Handles the pointer entered event.
Declaration
protected override void OnPointerEntered(PointerRoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.UI.Xaml.Input.PointerRoutedEventArgs | e |
OnPointerExited(PointerRoutedEventArgs)
Handles the pointer exited event.
Declaration
protected override void OnPointerExited(PointerRoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.UI.Xaml.Input.PointerRoutedEventArgs | e |
OnPreviewKeyDown(KeyRoutedEventArgs)
Handles the preview key down event.
Declaration
protected override void OnPreviewKeyDown(KeyRoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.UI.Xaml.Input.KeyRoutedEventArgs | e |
Events
ValueChanged
Invoke the event when the Value property is changed.
Declaration
public event EventHandler<MaskedTextBoxValueChangedEventArgs> ValueChanged
Event Type
Type | Description |
---|---|
System.EventHandler<MaskedTextBoxValueChangedEventArgs> |