Wpf – How to force WPF to re validate controls

idataerrorinfowpf

I have a screen with a business rules that displays some fields based on a business data and does not display others. i then play with Visibility to show/hide them.

My business object implements IDataErrorInfo.

The problem i have is that some of the validation pertains only when the field is shown.

In this code extract, the first IF makes the validation only if type_account is INTERNAL

string ValidateMinimumAmount()
{

    if (this.type_account != "INTERNAL")
       return null;

    if (this.account_minimum==null)
    {
        return "You must provide a minimum amount";
    }
    return null;
}

the problem i have is that since the initial state of my BO is NOT "Internal" then EVEN if after the user selects "INTERNAL" the validation never occurs again.

How can i "force" the validation to occur AFTER the first time.
Of course i have checked that if the initial state is "Internal" then it works

Best Answer

I'd advise you to notify errors more "properly" by adding an error property.

Here is a very understandable article which helped me, when I just started working in WPF as a complete beginner, you should take a look at this :

http://www.codeproject.com/KB/WPF/wpfvalidation.aspx

Related Topic