views:

30

answers:

2

Gentlemen,

I have a button bounded on Validation.HasError property of a textblock. The textblock has a validation rule that checks the value entered by user. The purpose of the binding is that the button should be disabled if the user enters a wrong data.

The problem is that the ValidationRule executes AFTER the binding. So when the user types a wrong value, the binding checks the HasError property of the textblock, which is FALSE, so the button is Enabled. And then the validationrule executes. It results in a reversed situation where the texblock is invalid and the button is enabled.

How could I specify which (binding and validation) executes first ?

Thanx

+1  A: 

What XAML are you using to bind the button to the textbox? Any change to the HasError property should trigger the binding to re-evaluate on the button regardless of at what stage validation is performed.

Are you sure your problem isn't that when the HasErrors property is false you want the IsEnabled property to be true and you're not reversing the value in the binding?

Martin Harris
A: 

Here's the XAML

 <Binding ElementName="integerInput" Path="HasValidationError"/>
 <Binding ElementName="doubleInput"  Path="HasValidationError"/>

I'm sure it isn't the case. The textblock control I'm talking about is a custom spinner (textbox with two +/- buttons). The content of the spinner is bound to a property in the viewmodel. Each time we click on + or - button a command is executed and increments or decrements the value in the textbox.

This is it.

Mohamed
This is not an answer. Please edit your question to add the additional information instead; this isn't a traditional forum like you may be used to. Thanks!
Michael Myers