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:
<TextBox>
<TextBox.Text>
<Binding Path="LastName">
<Binding.ValidationRules>
<my:EnterpriseValidationRule SourceTypeName="ValidationQuickStart.BusinessEntities.Customer, ValidationQuickStart.BusinessEntities" PropertyName="LastName" RulesetName="RuleSetA"/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Labels: .NET
14 Comments:
Great work!
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?
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.
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
Actually I am working on supporting the WPF databinding Converter property. Please drop me an email if you want to test this.
We are having issues whereby a combobox bindings for selectedvalue are broken when we use the errorprovider. are you aware of this issue?
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.
hi martin
tks for the quick response. I've tried the new codebase with the latest vab, but no luck
Cornerstone, can you drop me an email (bennedik@gmx.net).
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 ?
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]
{
get
{
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;
}
}
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?
Thks
Olivier
Hi martin, take a look at how I implemented validation:
http://blog.sandrino.be/?p=18
this integration soport BindingGroup Validations ?
thks.
Post a Comment
<< Home