简体   繁体   中英

database validation in WPF MVVM

在MVVM中,我们通过实现IDataErrorInfo在模型类中实现简单的验证,我的问题是如何在MVVM中验证用户已经存在的业务规则,例如用户已经存在等。目前我正在考虑在save命令上实现业务规则,但是问题是如何我以IDateErrorInfo显示错误的方式在验证错误模板中向用户显示错误

If you use WPF 4.5 you should take advantage of INotifyDataErrorInfo

You want an async validation here because you would need to reach out to the database.

here are some nice articles with background information:

WPF 4.5 – ASYNCHRONOUS VALIDATION https://anthymecaillard.wordpress.com/2012/03/26/wpf-4-5-validation-asynchrone/

WPF 4.5 – Part 1 : Asynchronous data validation http://www.jonathanantoine.com/2011/09/18/wpf-4-5-asynchronous-data-validation/

HTH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM