Table of Contents
Understanding Segment

EO.Wpf MaskedEdit supports multiple types of MaskedEditSegment. One can use EO.Wpf MaskedEdit to implement sophisticated patterns by combining these segment types. For example, consider a date time text box with the following format:

(4 digits year)-(Month Name)-(2 digits days)

Valid inputs can be "2001-January-01", "2005-March-31", etc. It can be implemented with 5 segments:

Segment Remarks
NumericMaskedEditSegment With the following properties set:
StaticMaskedEditSegment With Value set to "-", this segment is a read only segment.
ChoiceMaskedEditSegment With Choices set to a list of names of the twelve months (January, February, etc.), user can not directly type in this segment, instead they can only choose one of the choice item.
StaticMaskedEditSegment With Value set to "-", this segment is a read only segment.
NumericMaskedEditSegment With the following properties set:

Below is the XAML code:

XAML
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:eo="http://schemas.essentialobjects.com/wpf/"
        xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib"
        Title="MainWindow" Height="250" Width="350">
    <StackPanel Margin="10">
        <eo:MaskedEdit PromptChar="_" Width="120" HorizontalAlignment="Left">
            <eo:NumericMaskedEditSegment Digits="4" Minimum="2000" Maximum="2100" TabPattern="[/-]"></eo:NumericMaskedEditSegment>
            <eo:StaticMaskedEditSegment Value="-"></eo:StaticMaskedEditSegment>
            <eo:ChoiceMaskedEditSegment Choices="January|Febuary|March|April|May|June|July|August|September|October|November|December" TabPattern="[/-]"></eo:ChoiceMaskedEditSegment>
            <eo:StaticMaskedEditSegment Value="-"></eo:StaticMaskedEditSegment>
            <eo:NumericMaskedEditSegment Digits="2" Minimum="1" Maximum="31"></eo:NumericMaskedEditSegment>
        </eo:MaskedEdit>
    </StackPanel>
</Window>

The above code produces the following result:

Note the above code also demonstrated a number of other features:

  • PromptChar. This is the characther that used to fill "blank" positions;
  • TabPattern. This is a regular expression pattern that is used to determine if a key stroke should be interpreted as tab key. For example, the above code set TabPattern to "[/-]", which matches either "/" or "-", so if user enter either "/" or "-" in the first segment (the year segment), it will automatically skip to the month segment.