Hi,
- in my scenario I have a Linq2SQL Data backend.
my Dataobjects implement IDataErrorInfo to catch errors like
Name==null
(fast to execute Validationrules that only require the value, nothing special so far )the Dataobjects are organized in a tree-structure, so each has a Parent and Children
How can I validate if a chosen Name is Unique under the Children of a Dataobjects' Parent?
The problem I'm facing is, that the unique Name validation requires a Database roundtrip which lags typing if UpdateSourceTrigger="PropertyChanged"
on the TextBox binding to the Name.
On the other hand, I could set UpdateSourceTrigger="LostFocus"
, but the problem with that is, that I enable/disable a "Save" button on valid/invalid data. Now in the invalid state you can't click the Save button, so there's no way the Textbox could lose Focus to update (only tabbing away which is ugly, but there are more "unusabilities" with LostFocus (e.g. Error keeps displaying while typing and thus changing the name).
what would be ideal was a way to say for individual validationrules to apply on different events like so:
<TextBox Grid.Column="1">
<TextBox.Text>
<Binding Path="Foldername">
<Binding.ValidationRules>
<wpfresources:UniqueChildValidationRule ValidationStep="UpdatedValue" **UpdateSourceTrigger="LostFocus"**>
... stuff here ...
</wpfresources:UniqueChildValidationRule>
<DataErrorValidationRule **UpdateSourceTrigger="PropertyChanged"**/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
What is the best way to solve this?
EDIT
This MSDN article seems to suggest, that a BindingGroup would be the way to go. I'll look into that...