Tomtom
Tomtom

Reputation: 9394

Check TextBox-Validation in ViewModel

I have a TextBox where the Text-Property is binded to a double-value. Now I want to check if the validation of the TextBox is ok in the viewmodel. I currently have no idea how to do this.

How can I do this?

Upvotes: 0

Views: 241

Answers (2)

Aleksey
Aleksey

Reputation: 1347

And for validate use IDataErrorInfo (read more: http://blogs.msdn.com/b/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx)

Upvotes: 2

knov
knov

Reputation: 116

WPF can handle basic validation for you automatically, there will be cast exception in case of wrong user input.

For more elaborated validation you can use IDataErrorInfo. See for example http://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/

Upvotes: 0

Related Questions