davidsleeps
davidsleeps

Reputation: 9503

WPF Validation on submit using IDataErrorInfo

Is there a simple way to only show validation errors when a form is being submitted in WPF?

I'm using MVVM pattern, Caliburn.Micro and IDataErrorInfo. For most of my simple object add/edit forms, the constant red boxes is fine but for a particular screen I'd like to only show the error(s) once a user tries to submit- I am perfectly happy to have the submit button enabled all the time...

Upvotes: 2

Views: 1434

Answers (1)

Joe Mancuso
Joe Mancuso

Reputation: 2129

You could have a textbox that would bind to your viewmodel's IDataErrorInfo Error member. Have the form's Error member aggregate the list of errors from your form fields and only set the textblock to visibile on sumbit if Errors isn't empty.

Upvotes: 1

Related Questions