vrbilgi
vrbilgi

Reputation: 5793

WPF: data validation of submit button

Hi All I am very new to WPF and trying some sample program to learn it.

I have a application with following fields

    Username(TextBox)

    Password(PasswordBox)

    Button(Submit)

Requirement:

I have to do the data validation of username and password.

1.Validation when the cursor moves from the Box.

and

2.Validation when the Submit is pressed.

To achieve both which Trigger needs to be used. and how to acieve code for my second Requirement.

If you can share any sample code or direct me to some link it will be very helpful.

Upvotes: 0

Views: 1069

Answers (1)

myermian
myermian

Reputation: 32505

You need to look into using the IDataErrorInfo interface.

But, I'd definitely recommend looking into MVVM first. There are numerous frameworks built to help you:

Good resources that use IDataErrorInfo:

Upvotes: 1

Related Questions