Skip to content

SyncfusionExamples/How-to-set-null-value-in-WPF-DateTimeEdit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to Set Null Value in WPF DateTimeEdit

This example demonstrates how to allow null values in the Syncfusion WPF DateTimeEdit control. By default, DateTimeEdit requires a valid date and time value, but in many real-world scenarios, you may want to allow users to clear the value or represent an empty state. This is especially useful in forms where the date field is optional or when you need to reset the control programmatically.

Why This Is Useful

  • Optional Fields: Ideal for forms where date selection is not mandatory.
  • Reset Functionality: Allows clearing the date programmatically.
  • Better UX: Displays custom text when no date is selected.

Key Properties

  • IsEmptyDateEnabled: Enables empty date selection.
  • NullValue: Represents the null state.
  • NoneDateText: Custom text displayed when no date is selected.
  • ShowMaskOnNullValue: Controls whether the mask is shown when the value is null.

Code Example

XAML

<syncfusion:DateTimeEdit x:Name="dateTimeEdit"
                         Height="23"
                         Width="150"
                         IsEmptyDateEnabled="True"
                         IsVisibleRepeatButton="True"
                         NullValue="{x:Null}"
                         NoneDateText="No date is selected"
                         ShowMaskOnNullValue="False" />

C#

DateTimeEdit dateTime = new DateTimeEdit
{
    Height = 25,
    Width = 150,
    IsEmptyDateEnabled = true,
    IsVisibleRepeatButton = true,
    NullValue = null,
    NoneDateText = "No date is selected",
    ShowMaskOnNullValue = false
};

this.Content = dateTime;

Output

Null value in WPF DateTimeEdit

About

This repository contains the sample that how to set the null value in WPF DateTimeEdit control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages