Skip to content

Commit 9de64a4

Browse files
authored
Merge pull request #2 from SyncfusionExamples/985360
985360: Updated ReadMe file
2 parents cc7e0c1 + 0f30cd7 commit 9de64a4

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1-
# How-to-set-null-value-in-WPF-DateTimeEdit
2-
This repository contains the sample that how to set the null value in WPF DateTimeEdit control.
1+
# How to Set Null Value in WPF DateTimeEdit
2+
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.
3+
4+
## Why This Is Useful
5+
- **Optional Fields**: Ideal for forms where date selection is not mandatory.
6+
- **Reset Functionality**: Allows clearing the date programmatically.
7+
- **Better UX**: Displays custom text when no date is selected.
8+
9+
## Key Properties
10+
- **IsEmptyDateEnabled**: Enables empty date selection.
11+
- **NullValue**: Represents the null state.
12+
- **NoneDateText**: Custom text displayed when no date is selected.
13+
- **ShowMaskOnNullValue**: Controls whether the mask is shown when the value is null.
14+
15+
## Code Example
16+
**XAML**
17+
```XAML
18+
<syncfusion:DateTimeEdit x:Name="dateTimeEdit"
19+
Height="23"
20+
Width="150"
21+
IsEmptyDateEnabled="True"
22+
IsVisibleRepeatButton="True"
23+
NullValue="{x:Null}"
24+
NoneDateText="No date is selected"
25+
ShowMaskOnNullValue="False" />
26+
```
27+
28+
**C#**
29+
```C#
30+
DateTimeEdit dateTime = new DateTimeEdit
31+
{
32+
Height = 25,
33+
Width = 150,
34+
IsEmptyDateEnabled = true,
35+
IsVisibleRepeatButton = true,
36+
NullValue = null,
37+
NoneDateText = "No date is selected",
38+
ShowMaskOnNullValue = false
39+
};
40+
41+
this.Content = dateTime;
42+
```
43+
44+
## Output
45+
46+
![Null value in WPF DateTimeEdit](output.png)

0 commit comments

Comments
 (0)