Hi All I a开发者_如何学Gom 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.
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:
- Prism
- WAF (WPF Application Framework)
- Caliburn
- Silverlight.FX
- MVVM Light Toolkit
- Google Search (In case you just want to find one on your own)
- Stackoverflow Question (This discusses the different frameworks and their pros/cons).
Good resources that use IDataErrorInfo:
- General Example
- Josh Smith's article
- John Dolinger's Video (MY FAVORITE -- because he shows you how people normally do it, and how to change it to a nice MVVM pattern).
精彩评论