开发者

Prevent Save when Validation Errors occur on WPF DataGrid

开发者 https://www.devze.com 2023-02-08 11:23 出处:网络
Currently, I have a DataGrid which is bound to some data in my ViewModel. I have ValidationRules set up for the Rows, and the Columns. What I would like to do is prevent the user from saving the file

Currently, I have a DataGrid which is bound to some data in my ViewModel. I have ValidationRules set up for the Rows, and the Columns. What I would like to do is prevent the user from saving the file if there are any Validation Errors. I am using the RelayCommands class to route the Open, Save, etc commands to my ViewModel开发者_如何转开发.


Check the below links

Disable Save button in WPF if validation fails

Using WPF Validation rules and disabling a 'Save' button

http://babaandthepigman.wordpress.com/2010/02/14/wpf-commanding-and-data-annotations-validation/

Hope this helps...


You might be interested in the BookLibrary sample application of the WPF Application Framework (WAF). It disables the Save button when a validation error is active (e.g. DataGrid).

0

精彩评论

暂无评论...
验证码 换一张
取 消