Skip to content
SeRgI1982 edited this page Aug 30, 2017 · 1 revision

WPF have two interfaces supporting validation:

  • IDataErrorInfo,
  • INotifyDataErrorInfo.

The second one (INotifyDataErrorInfo) is a newer one and have much more features than former solution:

TimesheetEntryView

Create ValidationObject class which will be implemented INotifyDataErrorInfo interface.

Using DataAnnotations attributes create basic validations for the fields:

  • ProjectId - filed is required
  • WorkTitle - character length between 2 and 50.

Create Custom Validators:

  • TimeSpent - time spent for specific Task (Work Title) can't be longer than 8 hours,
  • DateStarted - time spent on Sunday can't be longer than 2 hours.

Validate data before Add/Update timesheet entry (operation can be done only if data are valid).

Create custom ErrorTemplate - the red circle should be visible when validation fails and should be placed on the right side - next to the control (hint: adorner).
ToolTip should present error message.

Clone this wiki locally