Wednesday, April 25, 2012

WPF, Validation, and Adorner Decorator

So I was working on a little project in WPF, using Caliburn Micro.  Was coming along well, but I had yet to put together validation.  I managed to cobble something together based on

Paul Stovell's WPF Validation at Codeplex
Beth Massi on Displaying WPF Validation

and more specific to Caliburn Micro:

Lyquidity's Caliburn Micro Validation code

My App.xml looked a little like this:

but I was having a problem:

  • My errors were definitely being checked, and validation was "working"
  • Anything I added to  Style.Triggers  was changing the display of the element itself (e.g. the background colour)
  • Nothing I added to  Validation.ErrorTemplate  was changing anything else
After much wailing and gnashing of teeth, I found the following article:



All I needed to do was to wrap my control code in an <AdornerDecorator> tag...

- Gavin

No comments:

Post a Comment