Back to Devexpress

TextEdit.Mask Property

wpf-devexpress-dot-xpf-dot-editors-dot-textedit-778191e7.md

latest5.2 KB
Original Source

TextEdit.Mask Property

Gets or sets a mask expression. This is a dependency property.

Namespace : DevExpress.Xpf.Editors

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public string Mask { get; set; }
vb
Public Property Mask As String

Property Value

TypeDescription
String

A string representing a mask expression.

|

Remarks

When the editor’s value is set using the Text property, the editor’s value is of System.String type and the Numeric and DateTime mask types may apply incorrectly. Specify the editor’s value using the EditValue property to correctly apply mask settings.

Note

The following TextEdit descendants do not support the masked input:

Specify Mask in Design Time

You can use the Mask Editor to specify editor’s Mask.

Specify Mask in Code

xaml
<!-- Long date -->
<dxe:TextEdit Mask="D" MaskType="DateTime"
    MaskUseAsDisplayFormat="True" />
<!-- Currency -->
<dxe:TextEdit Mask="c" MaskType="Numeric"
    MaskUseAsDisplayFormat="True" />
<!-- Email address -->
<dxe:TextEdit Mask="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"
    MaskType="RegEx" MaskUseAsDisplayFormat="True" />

To learn more, see Masked Input.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Mask property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-synchronous-theme-preload-with-splashscreen/CS/ThemePreloadwithSplashscreen/ComplexWindow.xaml#L101

xml
EditValue="{Binding Path=Address.ZipCode, Mode=TwoWay}"
Mask="00000"
MaskType="Simple" />

wpf-scheduler-highlight-time-intervals/CS/SchedulerCellTemplate/MainWindow.xaml#L19

xml
<dxe:TextEdit EditValue="{Binding LunchStart, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                  Mask="HH:mm:ss" MaskType="DateTime" MaskUseAsDisplayFormat="True" Margin="4,0,4,0" />
</dxlc:LayoutItem>

wpf-reporting-use-custom-controls-for-editing-report-content-in-print-preview/CS/App.xaml#L17

xml
MaxValue="{Binding Path=(dxp:DocumentPreviewControl.ActualViewer).DataContext.DateTimeMax, RelativeSource={RelativeSource Self}}"
              MaskUseAsDisplayFormat="True" Mask="MMMM dd, yyyy" ShowWeekNumbers="True" ShowToday="True" Name="PART_Editor" />
</DataTemplate>

wpf-data-grid-create-custom-gridcontrol-that-displays-horizontal-columns/CS/dxExample/MainWindow.xaml#L16

xml
<DataTemplate x:Key="intCellTemplate">
    <dxe:TextEdit Name="PART_Editor" MaskType="Numeric" Mask="d"/>
</DataTemplate>

wpf-pivot-grid-define-custom-cell-template-to-performing-data-editing/CS/HowToEditCell/MainWindow.xaml#L37

xml
local:PivotGridEditHelper.LostFocusCommand="{x:Static local:PivotGridEditHelper.Enter}"
Mask="[0-9]*\.[0-9]{0,2}"
MaskType="RegEx">

See Also

TextEdit Class

TextEdit Members

DevExpress.Xpf.Editors Namespace