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

RadNumericUpDown Validation Using IDataErrorInfo Interface

Updated on Sep 15, 2025

Environment

Product Version2022.3.1109
ProductRadNumericUpDown for WPF

Description

How to validate the Value property of the RadNumericUpDown control on custom criteria.

Solution

To achieve this functionality, you can implement the IDataErrorInfo interface in your view model.

Implementing IDataErrorInfo interface

C#
    public class NumericUpDownViewModel : ViewModelBase, IDataErrorInfo
    {
    	private double numericUpDownValue;

        public NumericUpDownViewModel()
        {
            this.NumericUpDownValue = -5;
        }

        public double NumericUpDownValue
        {
            get { return this.numericUpDownValue; }
            set
            {
                this.numericUpDownValue = value;
                this.OnPropertyChanged(nameof(this.NumericUpDownValue));
            }
        }

        public string Error
        {
            get { return this[string.Empty]; }
        }

        public string this[string name]
        {
            get
            {
                string result = null;

                if (name == "NumericUpDownValue")
                {
                    return this.ValidateValue();
                }

                return result;
            }
        }

        private string ValidateValue()
        {
            if (this.NumericUpDownValue < 0)
            {
                return "Value cannot be a negative number";
            }

            return null;
        }
    }

Binding the Value property of RadNumericUpDown

XAML
    <telerik:RadNumericUpDown Value="{Binding NumericUpDownValue, Mode=TwoWay, ValidatesOnDataErrors=True}" UpdateValueEvent="PropertyChanged"/>

In order for the RadNumericUpDown control to show its Validation.ErrorTemplate when an error occurs, set the ValidatesOnDataErrors property of the Binding instance to True.

RadNumericUpDown with a validation error and error message

RadNumericUpDown with a validation error and error message

In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support