Articles in this section
Category / Section

How to set null value in DateTimeEdit control ?

1 min read

If you want to set the null value for WPF DateTimeEdit control, you need to use the NullValue property. You can enable it only by setting the IsEmptyDateEnabled property to true and ShowMaskOnNullValue property to false. If the ShowMaskOnNullValue property true, then datetime mask is shown.

XAML

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

C#

DateTimeEdit dateTime = new DateTimeEdit();
dateTime.Height = 25;
dateTime.Width = 150;
dateTime.IsEmptyDateEnabled = true;
dateTime.IsVisibleRepeatButton = true;
dateTime.NullValue = null;
dateTime.NoneDateText = "No date is selected";
dateTime.ShowMaskOnNullValue = false;
this.Content = dateTime;

Output:

Null value set in WPF DateTimeEdit

 

Sample: View sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment