Songhay Studio: finally, some flippant remarks about XAML Validation
I’ve been deprioritizing a look into XAML-based Validation. Years ago I somehow got the impression that Validation was “confused” or “incomplete.” Now I can say that there are two broad categories of Validation:
- There is Validation for
System.Windows.Controls
. - There is Validation for
System.ComponentModel.DataAnnotations
viaINotifyDataErrorInfo
.
There are probably more categories of XAML-based Validation but I flippantly consider those ‘legacy’ alternatives. My other wild assertion is that Windows-controls Validation is mutually exclusive to Component-Model Validation. For example, as of this writing, the Validation.ClearInvalid()
or Validation.AddErrorHandler()
methods for Windows have no effect on Component-Model errors.
The Validation.ValidationAdornerSite
and Validation.ValidationAdornerSiteFor
properties are almost useless to me because they redirect Validation adornment from, say, a TextBox
to a Label
. I would like to have the option of adorning one or more “sites” including the original TextBox
.
I have prepared a basic, Component-Model Validation sample for WPF. It’s in my BiggestBox on CodePlex:
I also have a LINQPad exploration of Windows-controls Validation as a GitHub Gist: