views:

379

answers:

3

I have several forms with many textboxes/comboboxes, and I would like to have the "Save" button disabled while at least one of the fields are invalid. I've been able to setup some custom ValidationRules, like so (textbox example shown):

<Binding Path="Name">
    <Binding.ValidationRules>
        <my:TextFieldNotEmpty/>
    </Binding.ValidationRules>
</Binding>

My question is: how can I set my form up so that, when even 1 validation rule fails, the "Save" button is not enabled? Is there a standard way of handling a situation (a trigger, perhaps), or is this a place where WPF falls short?

+1  A: 

Will this answer your question? Detecting WPF Validation Errors

Vegar
A: 

You might be interested in the BookLibrary sample application of the WPF Application Framework (WAF). It shows how to use validation in WPF and how to control the Save button when validation errors exists.

jbe