One of the few features we needed to cut from Enterprise Library 3.0 was a Windows Presentation Foundation “integration adapter” for the Validation Application Block. This was a tough call, and wasn’t made because we didn’t think it was an important scenario – rather it was because we were extremely pressed for time and didn’t have enough WPF experience on the team for us to accurately predict how long it would take to implement a solid solution. Still we did do enough prototyping to ensure that it would be possible to build such an adapter, with the expectation that we, or someone else, would do so in the future.
Now I’m pleased to announce that that “someone else” has materialized in the form of Martin Bennedik – he has just written and published his WPF Integration Adpater for the Validation Application Block. Conceptually this works much the same way as the Windows Forms and ASP.NET Integration Adapters, in that it lets you bind UI controls with specific types and properties, and automatically validate the data in the controls using the validation rules specified on the types using attributes or configuration. Martin’s provider integrates with WPF by providing a EnterpriseValidationRule class, which hooks into the WPF validation machinery, and an ErrorProvider class is able to extend controls to trigger the validation and display errors.
If you are using or experimenting with WPF, this is a great addition to the Validation Application Block. Please stop by Martin’s blog to thank him for his contribution and provide him any feedback on the use of this extension.