Indeed your question reeks like homework ![]()
Have a look at http://www.codeproject.com/Articles/15239/Validation-in-Windows-Presentation-Foundation
And next time please use a search engine, you might start giving the impression that students nowadays are even too lazy to look for examples ![]()