The INotifyDataErrorInfo
interface has been a .NET citizen for some time, at least for Silverlight developers. It brought a new improved system for validating data, which we now have in WPF, with all of its power and interesting things to discover.
In this recipe we will explain how to use this new powerful feature of WPF in .NET 4.5.
First, open Visual Studio 2012 and create a new project. We will select the WPF Application template from the Visual C# category and name it
WPFValidation
.Create a class named
BaseClass.cs
. Edit it and implement the interfacesINotifyPropertyChanged
andIDataErrorInfo
. We can copy the following code inside it:public abstract class BaseClass : INotifyPropertyChanged, INotifyDataErrorInfo { private static Dictionary<string, PropertyChangedEventArgs> argumentInstances = new Dictionary<...