WPF 03 - Model Validation with IDataErrorInfo 例子

WPF 03 - Model Validation with IDataErrorInfo 例子

WPF 03 - Model Validation with IDataErrorInfo 例子_第1张图片

 

WPF 03 - Model Validation with IDataErrorInfo 例子_第2张图片

WPF 03 - Model Validation with IDataErrorInfo 例子_第3张图片

 

WPF 03 - Model Validation with IDataErrorInfo 例子_第4张图片

VIEWMODEL:

 WPF 03 - Model Validation with IDataErrorInfo 例子_第5张图片

 

界面:

WPF 03 - Model Validation with IDataErrorInfo 例子_第6张图片

 

运行结果:

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

WPF 03 - Model Validation with IDataErrorInfo 例子_第7张图片

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

WPF 03 - Model Validation with IDataErrorInfo 例子_第8张图片

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

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

提示的另一种样式:

WPF 03 - Model Validation with IDataErrorInfo 例子_第9张图片

 

转载于:https://www.cnblogs.com/watermarks/p/8469314.html

你可能感兴趣的:(WPF 03 - Model Validation with IDataErrorInfo 例子)