WPF Validation in an ElementHost control

Posted by Jon Mitchell on Stack Overflow See other posts from Stack Overflow or by Jon Mitchell
Published on 2009-07-07T14:58:55Z Indexed on 2010/04/15 11:13 UTC
Read the original article Hit count: 444

Filed under:
|
|

I've got a WinForms form that contains an ElementHost control (which contains a WPF UserControl) and a Save button.

In the WPF UserControl I've got a text box with some validation on it. Something like this...

<TextBox Name="txtSomething" ToolTip="{Binding ElementName=txtSomething, Path=(Validation.Errors).[0].ErrorContent}">
    <Binding NotifyOnValidationError="True" Path="Something">
        <Binding.ValidationRules>
            <commonWPF:DecimalRangeRule Max="1" Min="0" />
        </Binding.ValidationRules>
    </Binding>
</TextBox>

This all works fine. What I want to do however, is disable the Save button while the form is in an invalid state.

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about validation