”WinRT XAML Validation” is a library to enable comprehensive validation of user input in C#/XAML WinRT apps. The implemented validation approach is based on Data Annotations and the
ValidationAttribute class and extends those principles for implicit and explicit synchronous and asynchronous validation of properties and entities as a whole.
The library gives you the following functionality:
- Validation Attributes: Define custom validation logic with Data Annotations on your model entities. The library contains extended base attributes for validation with support of warnings/errors, async validation and validation logic, that
spans more than one property.
- Implicit Validation Execution: Use the
ValidationBindableBase class on your model entities to perform validation. You can opt-in to let validation execute automatically when a entity property changes (implicit validation).
- Explicit Validation Execution: Instead of running validation everytime a property changes on your model entities, you can call the
ValidationBindableBase.ValidateAsync() method explicitly to validate the defined validation attributes.
- Manual Validation: Besides the use of validation attributes to define validation logic, you can easily perform custom validation logic and add corresponding validation messages to a Dictionary, using the
ValidationBindableBase.ValidationMessages.Add() method. The provided UI controls will update themselves automatically.
- Validation UI Controls: There are two easy-to-use XAML UI controls to show validation messages. First there is the
ValidationPanel control that wraps a control whose bound property should be validated (for example a
TextBox). If validation fires for the property, the
ValidationPanel will show a red border (orange for warnings) and optionally the validation message. More than one validation message is supported. The second control is the
ValidationSummary, which can show aggregated validation messages for a whole form and its bound entity. Both controls update immediately when validation messages change, even in async scenarios.
Take a look at the
Documentation page for more information how to use the library. And of course feel free to download the current release or the sourcecode and take a look at the readme files and the code documentation.