Back to Devexpress

DateEdit.DefaultTime Property

wpf-devexpress-dot-xpf-dot-editors-dot-dateedit-cd8435cb.md

latest3.0 KB
Original Source

DateEdit.DefaultTime Property

Gets or sets the value displayed in the empty editor when a user starts to enter time. This property is in effect only if the editor operates TimeOnly data. This is a dependency property.

Namespace : DevExpress.Xpf.Editors

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public TimeOnly? DefaultTime { get; set; }
vb
Public Property DefaultTime As TimeOnly?

Property Value

TypeDefaultDescription
Nullable<TimeOnly>TimeOnly.MinValue

The value displayed in the empty editor when a user starts to enter data.

|

Remarks

If the editor’s value is not set, the editor displays the DefaultTime when a user opens the drop-down time picker.

The DefaultDate property does not affect the value that the empty editor returns. Use the BaseEdit.NullValue property to specify the editor value when its value is null.

For more information about DateOnly and TimeOnly support in the DateEdit control, refer to the following section: Interact with DateOnly and TimeOnly Data.

Example: Use Spin Buttons to Edit a TimeOnly Value

The following code snippet allows users to press spin buttons to increase or decrease a TimeOnly value:

xaml
<dxe:DateEdit MaskType="TimeOnly" AllowDefaultButton="False" 
              PopupOpening="DateEdit_PopupOpening" 
              DefaultTime="10:30" MinTime="7:30">
    <dxe:ButtonEdit.Buttons>
        <dxe:SpinButtonInfo SpinDownClick="SpinButtonInfo_SpinDownClick"
                            SpinUpClick="SpinButtonInfo_SpinUpClick"/>
    </dxe:ButtonEdit.Buttons>
</dxe:DateEdit>
csharp
void SpinButtonInfo_SpinDownClick(object sender, RoutedEventArgs e) {
    ((ButtonEdit)BaseEdit.GetOwnerEdit((SpinButton)sender)).SpinDown();
}
void SpinButtonInfo_SpinUpClick(object sender, RoutedEventArgs e) {
    ((ButtonEdit)BaseEdit.GetOwnerEdit((SpinButton)sender)).SpinUp();
}
private void DateEdit_PopupOpening(object sender, OpenPopupEventArgs e) {
    e.Cancel = true;
}

See Also

DateEdit Class

DateEdit Members

DevExpress.Xpf.Editors Namespace