Model Validation with IDataErrorInfo 例子

时间:2021-11-08 04:51:36

WPF 03 - Model Validation with IDataErrorInfo 例子

Model Validation with IDataErrorInfo 例子

Model Validation with IDataErrorInfo 例子

Model Validation with IDataErrorInfo 例子

Model Validation with IDataErrorInfo 例子

VIEWMODEL:

Model Validation with IDataErrorInfo 例子

界面:

Model Validation with IDataErrorInfo 例子

运行功效:

当为空时,,error被触发。边框变为红色。

Model Validation with IDataErrorInfo 例子

如何进化成下面有文字提示呢?

Model Validation with IDataErrorInfo 例子

只需要在界面code里改一下:增加label Content (grid改成stackPanel)

如何打消 WPF textbox红色外框 error提示?设置Validation.ErrorTemplate = "{x:Null}"

提示的另一种样式:

Model Validation with IDataErrorInfo 例子