Intersoft ClientUI Documentation
UXDateTimeEditor

UXDateTimeEditor provides text input control with full support for standard and custom format DateTime entry. UXDateTimeEditor also provides MaxValue and MinValue properties to control the minimum and maximum date time entry. It also includes an innovative feature such as caret advancing. When enabled, the caret is moved automatically to the next editable section when the input for the current section succeeded.

UXDateTimeEditor

TextBox Control

UXDateTimeEditor derives from UXTextBox, which means all the UXTextBox feature is available in the UXMaskedInput such as CommandWatermarkText, etc. For more info about UXTextBox, see UXTextBox Overview.

Using UXDateTimeEditor

UXDateTimeEditor has two date and time format that you can set through the EditMask and DisplayMask property. The format specified in EditMask is used during editing mode, while the format specified in DisplayMask is used to display the formatted date time value.

XAML
Copy Code
<Intersoft:UXDateTimeEditor Width="200" Height="24" EditMask="dd/MM/yyyy" DisplayMask="yyyy MMMM dd"/>

If you want to use the EditMask as DisplayMask you can set the UseEditMaskAsDisplayMask to True. By enabling this property, UXDateTimeEditor will ignore the DisplayMask value if it is filled.

Edit mode is triggered if the UXDateTimeEditor has focus and is not read only. By default the caret is positioned at the first editable position. Display mode is triggered if the UXDateTimeEditor does not has focus.

The accepted date time format in Display and Edit mode could be read on Accepted DateTime Format section. By default the EditMask is set to standard format g.

Allow Null Value

UXDateTimeEditor also has AllowNull property which is set to False by default. When enabled, the Value of the UXDateTimeEditor can be set to null. In most cases, there are two ways to set the control's value to null such as described in the following:

The Text property should not be set by the user. The setter is public for compliance with UXTextBox in designer mode.

Accepted DateTime Format

The UXDateTimeEditor accept standard and custom .NET DateTime format in the EditMask and DisplayMask. Some of the format is not parsed in EditMask because it is only used as a DisplayMask.

Standard Format

Valid EditMask Format Specifier Description
V d Short date pattern.
V D Long date pattern.
V f LFull date/time pattern (short time).
V F Full date/time pattern (long time).
V g General date/time pattern (short time).
V G General date/time pattern (long time).
V M, m Month/day pattern.
V O, o Round-trip date/time pattern.
V R, r RFC1123 pattern.
V s Sortable date/time pattern.
V t Short time pattern.
V T Long time pattern.
V u Universal sortable date/time pattern.
X U Universal full date/time pattern.
V Y, y Year month pattern.

Custom Format

Format Specifier Description
d The day of the month, from 1 through 31.
dd The day of the month, from 01 through 31.
ddd The abbreviated name of the day of the week.
dddd The full name of the day of the week.
f The tenths of a second in a date and time value.
ff The hundredths of a second in a date and time value.
fff The milliseconds in a date and time value.
ffff The ten thousandths of a second in a date and time value.
fffff The hundred thousandths of a second in a date and time value.
ffffff The millionths of a second in a date and time value.
fffffff The ten millionths of a second in a date and time value.
F If non-zero, the tenths of a second in a date and time value.
FF If non-zero, the hundredths of a second in a date and time value.
FFF If non-zero, the milliseconds in a date and time value.
FFFF If non-zero, the ten thousandths of a second in a date and time value.
FFFFF If non-zero, the hundred thousandths of a second in a date and time value.
FFFFFF If non-zero, the millionths of a second in a date and time value.
FFFFFFF If non-zero, the ten millionths of a second in a date and time value.
g, gg The period or era.
g, gg The period or era.
h The hour, using a 12-hour clock from 1 to 12.
hh The hour, using a 12-hour clock from 1 to 12.
H The hour, using a 24-hour clock from 0 to 23.
HH The hour, using a 24-hour clock from 00 to 23.
K Time zone information.
m The minute, from 0 through 59.
mm The minute, from 00 through 59.
M The month, from 1 through 12.
MM The month, from 01 through 12.
MMM The abbreviated name of the month.
MMMM The full name of the month.
s The second, from 0 through 59.
ss The second, from 0o through 59.
t The first character of the AM/PM designator..
tt The AM/PM designator.
y The year, from 0 to 99.
yy The year, from 00 to 99.
yyy The year, with a minimum of three digits.
yyyy The year as a four-digit number.
yyyyy The year as a five-digit number.
z Hours offset from UTC, with no leading zeros.
zz Hours offset from UTC, with a leading zero for a single-digit value.
zzz Hours and minutes offset from UTC.
: The time separator.
/ The date separator.
"string", 'string' Literal string delimiter.
% Defines the following character as a custom format specifier.
\ The escape character.

Using MaxValue and MinValue

MaxValue and MinValue property is available if you wish to limit the accepted date time value, by default this value is null so any valid date time value is accepted. Inputting date time value outside the accepted range cause the UXDateTimeEditor to throw an error.

By setting the IsValidating property to True, user could manually trigger the UXDateTimeEditor validation process. If the value is invalid an error will be raised and IsValueError property is automatically set to True.

XAML
Copy Code
<Intersoft:UXDateTimeEditor Width="200" Height="24" EditMask="g" UseEditMaskAsDisplayMask="True" MaxValue="12/31/2010" MinValue="12/1/2010"/>
UXDateTimeEditor

Enabling Automatic Advancing Caret

UXDateTimeEditor has IsAdvancingCaret property to automatically move to the next editable section after the highlighted section does not have any other input possibilities.

For example inputting 9 in the date section automatically move the caret to the next editable section if the IsAdvancingCaret is enabled. Using the snippet below and United States culture the next editable section after date is year section.

XAML
Copy Code
<Intersoft:UXDateTimeEditor Width="200" Height="24" EditMask="g" UseEditMaskAsDisplayMask="True" IsAdvancingCaret="True"/>

Culture Support

The UXDateTimeEditor supports localization by setting the Culture property to a CultureInfo object. Culture has affects on certain date time pattern, for instances, the Days in Week pattern and Long Month Name.

For example, the 22 December 2010 with F format in different culture shows the results as follows:

Customizing Spinning Behavior

You can spin the value of UXDateTimeEditor by using Arrow Up and Arrow Down key. This will change the value locally or globally depending on value of SpinMode property.

The following list describes different behavior of SpinMode available in UXDateTimeEditor.

Understanding UXDateTimeEditor Command

UXDateTimeEditor is built around the commanding semantics which allows the value changing interaction to be executed through declarative definition in the XAML markup. The commanding semantics is also an ideal approach for MVVM pattern development.

UXDateTimeEditor already includes several predefined commands to change the selected value that you can use in your application.

XAML
Copy Code
<Intersoft:UXPage 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:Intersoft="http://intersoft.clientui.com/schemas"
        x:Class="MaskedInputTestSilverlightApp.UXPageDateTimeSample" 
        Title="UXPageDateTimeSample Page"
        d:DesignWidth="640" d:DesignHeight="480">
        
        <Grid x:Name="LayoutRoot">
        <StackPanel>
            <Intersoft:UXDateTimeEditor x:Name="dateTime1" Width="150" Height="24" UseEditMaskAsDisplayMask="True" EditMask="dd MMM yyyy" IsAdvancingCaret="true"/>
            <Intersoft:UXButton Name="btn1" Content="Spin Up" Command="Intersoft:DateTimeEditorCommands.SpinUp" CommandTarget="{Binding ElementName=dateTime1}"/>
            <Intersoft:UXButton Name="btn2" Content="Spin Down" Command="Intersoft:DateTimeEditorCommands.SpinDown" CommandTarget="{Binding ElementName=dateTime1}"/>
        </StackPanel>
        </Grid>
</Intersoft:UXPage>

Keyboard Support

Base on the currently highlighted selection, certain input is blocked. For example, when editing day, month, year, hour, minute, second only numeric key is allowed. On the other hand while editing a long month both numeric and letters is accepted.

Most of special key combination is implemented except Ctrl + Z. However due to the nature of the control some of the text operation will be different. The following are list of different behavior of text operation in UXDateTimeEditor.

See Also