0

I trying to display validation error messages as summary in wpf. Right now I'm able to display it as tooltip for each control using ErrorProvider.

My requirement is that I should display validation error messages of all controls in one place as a summary.

Please let me know how it can be done.

Thanks, Vinutha

2 Answers 2

1

What I do is store all the error messages in a dictionary, indexed by property name, this is where I read from in the IDataErrorInfo indexer. This dictionary is populated via validation code.

You could also create an ObservableCollection where you populate any error messages from the values in the dictionary and bind this to an ItemsControl on your UI. Or implement an ObservableDictionary to store your error messages.

Previously I have used a message box to display this collection of errors when the user presses save, for example.

Sign up to request clarification or add additional context in comments.

Comments

1

You are definitely going to need a sample project here.

What I do is create a StackPanel with a TextBlock for each TextBox you need to have filled out. Then you bind to the Validation of the element.

Here is a sample project I made when needed to do almost exactly what you are asking. I tracked it down and through it up on my blog for you.

TextBox Validation – How to bind properties of the Validation of a TextBox?

4 Comments

Glad it worked for you...don't forget to mark this post as answered.
This worked but do i have to create a seperate class like "TextBoxNotEmptyValidationRule" for each control as my validation error messages are different for each control.
I wonder if you could add a String DependencyProperty to the TextBoxValidationRule ojbect, and then maybe you could have one Object and set the String's value in the XAML and then the string is what is returned. If you aren't familiar with dependency properties let me know.
Actually, just a string property is enough. I guess it doesn't have to be a DependencyProperty. And there are all kinds of problems trying add a DP because ValidationRule does inherit DependencyObject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.