New to Telerik UI for WPFStart a free 30-day trial

Property level validation

Updated on Sep 24, 2025

RadDataForm provides data validation of the user input. Data Validation enables you to take complete control of the data entered in the fields of the data form.

Generally, the built-in validation will be performed once the edit has been committed and the RadDataForm will be visualized as follows:

WPF RadDataForm Built-In Validation

In the case above the Framework handles the validation and it fails due to type incompatibility.

However, you are free to perform your own custom logic when validating. The first approach would be to handle the ValidatingItem event of the RadDataForm. You may subscribe to it, define the validation rules you want to apply and cancel the default validation.

For example:

Example 1: Handling the ValidatingItem Event

C#
	private void DataForm1_ValidatingItem(object sender, System.ComponentModel.CancelEventArgs e)
	{
	    var employer = this.DataForm1.CurrentItem as Employee;
	    if (employer.Salary < 1000)
	    {
	      	e.Cancel = true;
	        RadWindow.Alert("You have to raise " + employer.LastName + " salary");
	    }
	}

In this case the RadDataForm will be displayed as the image below:

WPF RadDataForm with RadWindow Alert

Yet another approach applicable when defining custom fields is to specify the validation properties in the binding and perform the logic inside the property setter. For example:

Example 2: Perform the Validation inside the Property Setter

C#
	public DateTime StartingDate
	{
	    get
	    {
	        return this.startingDate;
	    }
	    set
	    {
	        if (value != this.startingDate)
	        {
	            if (value > DateTime.Now)
	            {
	                throw new ValidationException("Starting date should not be earlier than 2011");
	            }
	            else
	            {
	                this.startingDate = value;
	                this.OnPropertyChanged("StartingDate");
	            }
	        }
	    }
	}

The definition of the DataFormDataField should be like follows:

Example 3: Defining the DataFormDataField

XAML
	<telerik:DataFormDateField Label="Starting date" DataMemberBinding="{Binding StartingDate, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>

Once the validation is performed, the RadDataForm will be displayed as in the image below:

WPF RadDataForm with Property-Level Validation

Not finding the help you need?
Contact Support