Customizing the error template

In addition to the essential Errors and HasError properties, the Validation class also declares an ErrorTemplate Attached Property of type ControlTemplate. The default template assigned to this property is responsible for defining the red rectangle that surrounds UI fields that have validation errors associated with them.

However, this property enables us to change this template and so, we are able to define how validation errors are highlighted to the application users. As this property is an Attached Property, this effectively means that we could apply a different template to be displayed for each control in the UI. However, this cannot be recommended, because it could make the application look less consistent. ...

Get Mastering Windows Presentation Foundation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.