Hi everyone.
I'm having problems coming up with a good way to validate user input. I'm aware that I can implement IDataErrorInfo
to do simple validation on user input, and I have read several articles on the subject (such as this and this) without seeing the light. Let me explain the two problems I have:
Basically I'm implementing an application that allows the user to create users in a system. My viewmodel uses a set of WCF services to save its work. When someone wants to create a new user I can easily see how I can use IDataErrorInfo to disallow empty usernames being entered. But if the username is not empty and a call to the CreateUser
service fails because the username already exists, then how do I hightlight the user name textbox? My second problem is with two PasswordBox
'es that I have, Password and RepeatPassword. Since I cannot databind to the Password
property I don't see how I can use the IDataErrorInfo
approach to validate that the password is not empty. Furthermore I need to make sure that the two passwords are identical, so again this calls for some custom mechanism.
I'm by no means an expert on WPF and maybe I'm missing some obvious solution, so please, if you can, shed some light on how I can solve this.
Thanks in advance,
Klaus