DateValidationError Event

DatePicker.DateValidationError Event


Occurs when Text is set to a value that cannot be interpreted as a date or when the date cannot be selected.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public event EventHandler<DatePickerDateValidationErrorEventArgs> DateValidationError

After the DateValidationError event occurs, if you set the DatePickerDateValidationErrorEventArgs.ThrowException property to true, one of the following exceptions is raised:

Exception type



The text entered cannot be parsed to a valid date, and the exception is not suppressed.


The text entered parses to a date that is not selectable.

<DatePicker DateValidationError="eventhandler"/>

The following example creates a DatePicker that displays the dates in August 2009 and specifies that each Saturday and Sunday is not selectable.

The DatePicker handles the DateValidationError event, as shown in the following code. If the user enters a date that is not selectable, the example displays a message. If the user enters text that is not a valid date, an exception is thrown.

.NET Framework
Available since 4.0
Available since 2.0
Return to top
© 2015 Microsoft