Tuesday, May 01, 2007

Update of the WPF integration for the validation application block

In WPF databinding you can bind not only to a property of an object, but also to a path. For example, in the quickstart of the validation application block, the customer object contains an address object. You can now databind a textbox to the city with the expression Address.City, using the common dot notation:

<TextBox Text="{Binding Path=Address.City}"/>

I have now updated the ErrorProvider of the WPF integration for the validation application block to support these data bindings. You can now conveniently nest all the databound controls into a single ErrorProvider, and get automatic validation of the customer and address fields.

You can download the update here.

Here are some answers to questions I received about the WPF integration:

Question: How do I compile the sample application that is contained in your zip archive?

Answer: First, make sure you have the source code of the Enterprise Library 3.0 installed. You can find the business entities in the Quick Starts/Validation/CS directory. You can also extract the zip archive of the WPF integration into that directory and add the projects to the ValidationQuickStart project, and all references should be set.

Question: Can I use the EnterpriseValidationRule directly in my XAML, without using the ErrorProvider?

Answer: Yes, for example:



        <Binding Path="LastName">


            <my:EnterpriseValidationRule SourceTypeName="ValidationQuickStart.BusinessEntities.Customer, ValidationQuickStart.BusinessEntities" PropertyName="LastName" RulesetName="RuleSetA"/>







Anonymous James Peckham said...

Great work!

7:09 AM  
Anonymous Anonymous said...

First of all is there a reason to have the Enterprise Library's source code installed other than for referring the Business entities?
I have been trying to use your WPF Integration for VAB and am coming across this problem. I have set the path for references Validation.dll and Common.dll to EnterpriseLibrary 3.0\bin (signed version of the dll), but running the WPF sample project breaks. The sample works fine only if I set the path for Validation.dll and Common.dll to EntLib3Src\App Blocks\Src\Validation\bin\Debug (the unsigned version). Could you please explain?

6:03 AM  
Blogger Petr said...

Hi, does your integration invoke methods marked with [SelfValidation] attributes? I am unable to make this methods work and besides remoting this is the most probable reason. Thanks.

11:56 PM  
Anonymous Anonymous said...

Hi, the VAB QuickStart shows an example on how to validate that a textbox contains an int value (RewardPoints field), using the ValueConvert event of a ValidationProvider. Would your WPF integration cover this functionality?
Thanks in advance

12:09 AM  
Blogger Martin Bennedik said...

Actually I am working on supporting the WPF databinding Converter property. Please drop me an email if you want to test this.

3:15 AM  
Blogger CornerStone said...

We are having issues whereby a combobox bindings for selectedvalue are broken when we use the errorprovider. are you aware of this issue?

6:41 AM  
Blogger Martin Bennedik said...

Please check my latest update at http://www.bennedik.de/2008/05/wpf-integration-for-vab-update-for.html. Let me know if that solves the problem.

10:48 AM  
Blogger CornerStone said...

hi martin

tks for the quick response. I've tried the new codebase with the latest vab, but no luck

4:55 PM  
Blogger Martin Bennedik said...

Cornerstone, can you drop me an email (bennedik@gmx.net).

4:56 AM  
Blogger Elazar Neeman said...

Martin, first of all thanks for an excellent work. I have a question is it possible even where your validation mechanism detects error to update the data source ?

7:38 AM  
Blogger Quicoli said...

Hi, to make use of VAB in my WPF applications i do: my business classes implement IDataErrorInfo. And so i have:

public override string this[string columnName]
string result = null;
ValidationResults results = Validation.Validate(this);
EstaValido = results.IsValid;
if (!results.IsValid)
var validationMessage = results.FirstOrDefault(x => x.Key == columnName);
if (validationMessage != null)
result = validationMessage.Message;
return result;

9:52 AM  
Blogger olive_fr said...

I'm trying to use the WPF integration with the latest version of EntLibrary (4.1).

In the method Validate() of EnterpriseValidationRule the call to GetValidator() always returns null. I have traced the EntLibrary but I cannot find out why it returns null. The issue is that the validation doesn't work at all because no validator can be retrieved from the decorated properties.

Any advise on how to make it work?

11:40 PM  
Anonymous Anonymous said...

Hi martin, take a look at how I implemented validation:


11:24 AM  
Anonymous Anonymous said...

this integration soport BindingGroup Validations ?

5:04 PM  

Post a Comment

<< Home