INotifyDataErrorInfo
interface; for a detailed explanation of the WPF validation capabilities take a look a the following MSDN Magazine detailed article: https://docs.microsoft.com/en-us/archive/msdn-magazine/2010/june/msdn-magazine-input-validation-enforcing-complex-business-data-rules-with-wpfIRequireValidation
interface inherits from the built-in INotifyDataErrorInfo
interface, IRequireValidation
is defined as follows:AbstractViewModel
, the user is only required to inherit from the interface so to tell to the WPF infrastructure that the DataContext
of the View
is a class the implements INotifyDataErrorInfo
. Going deeper the IRequireValidation
interface exposes the following features:ValidationBehavior
enumeration allows to customize the validation engine behavior;TriggerValidation
method allows to programmatically “ask” to WPF to trigger the error status even on properties, valid or invalid, that has never been involved in a binding write operation; The typical scenario is a form with a submit button, if the user never fills the form but simply presses the submit button we want to visually show invalid properties and fields, the TriggerValidation
method is designed to achieve this.VaidationService
protected property.DataAnnotationValidationService<TViewModel>
that, as the name implies, works against the Data Annotation services, and add support for custom inline validation rules.INotifyDataErrorInfo
interface, in order to run the validation process, the second requirement is that each binding is configured to enable validation, since there are several properties to set to true this operation tends to be tedious and prone to errors; in order drastically simplify the validation setup Radical offers its own binding extension with everything setup as expected:EditorBinding
is a standard binding with everything already setup for validation, the EditorBinding
markup extension can be found in the http://schemas.radicalframework.com/windows/markup
xml namespace.ValidationCalledOnceFor( String propertyName )
that the infrastructure calls in order to understand if the given property has been validated at least once.DataAnnotationValidationService
.ctx
parameter in the above sample) passed to the rule evaluation lambda and the error generator lambda has the following signature: