Xceed Toolkit Plus for WPF v5.0 Documentation
Xceed.Wpf.Toolkit Assembly / Xceed.Wpf.Toolkit Namespace / MaskedTextBox Class
Members Example


In This Topic
    MaskedTextBox Class
    In This Topic
    Represents a control that lets users display and edit values based on a mask.
    Syntax
    'Declaration
     
    <LocalizabilityAttribute(LocalizationCategory.Text)>
    <ContentPropertyAttribute("Text")>
    <TemplatePartAttribute(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)>
    <StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)>
    <XmlLangPropertyAttribute("Language")>
    <UsableDuringInitializationAttribute(True)>
    <RuntimeNamePropertyAttribute("Name")>
    <UidPropertyAttribute("Uid")>
    <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
    <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
    Public Class MaskedTextBox 
       Inherits Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox
    'Usage
     
    Dim instance As MaskedTextBox
    [Localizability(LocalizationCategory.Text)]
    [ContentProperty("Text")]
    [TemplatePart(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)]
    [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
    [XmlLangProperty("Language")]
    [UsableDuringInitialization(true)]
    [RuntimeNameProperty("Name")]
    [UidProperty("Uid")]
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public class MaskedTextBox : Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox 
    Remarks

    The mask is specified via its Mask property.

    Example
    The following example shows how to create a MaskedTextBox with the Mask property set to a telephone number format.
    <xctk:MaskedTextBox Mask="(000) 000-0000" />
    The following example shows how to set the value of a MaskedTextBox. The Value property supports binding to any data type, but it is a String by default.
    <xctk:MaskedTextBox Mask="(000) 000-0000" Value="5551234567" />
    Literals can be included in the mask by setting the MaskedTextBox.IncludeLiterals to true.
    <xctk:MaskedTextBox Mask="(000) 000-0000" Value="(555) 123-4567" IncludeLiterals="True" />
    Prompt character can be included by using "_" in Value.
    <xctk:MaskedTextBox IncludePrompt= "True" Mask="(000) 000-0000" Value="(555) 12_-____" IncludeLiterals="True" />
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      System.Windows.Controls.Control
                         System.Windows.Controls.Primitives.TextBoxBase
                            System.Windows.Controls.TextBox
                               Xceed.Wpf.Toolkit.AutoSelectTextBox
                                  Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox
                                     Xceed.Wpf.Toolkit.MaskedTextBox
                                        Xceed.Wpf.Toolkit.PropertyGrid.Editors.PropertyGridEditorMaskedTextBox

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also