首先看一下ReportServer的表结构,非常简单:

【WPF】MVVM实践(下)

 

 

项目中的Model文件,除了有对应数据库表的字段的属性外,因为还实现了IDataErrorInfo接口,所以在Model中还会对属性值进行有效性验证,在最终用户界面上表现的结果是(端口号要求只能为数字):

 

 【WPF】MVVM实践(下)

这就是ReportServerModel实现接口IDataErrorInfo的作用了,部分代码:

 

#region IDataErrorInfo的成员
string IDataErrorInfo.Error // 该属性其实是不会被调用到的
{
get { return null; }
}

string IDataErrorInfo.this[string propertyName]
{
    
// 这里调用了自定义的GetValidationError函数,具体代码参考附件源码
get { return this.GetValidationError(propertyName); } 
}
#endregion

相关文章:

  • 2021-02-24
  • 2022-12-23
  • 2021-12-25
  • 2021-08-09
  • 2021-10-26
  • 2021-11-01
  • 2022-03-09
猜你喜欢
  • 2022-12-23
  • 2022-03-04
  • 2021-07-22
  • 2022-01-21
  • 2021-11-29
  • 2021-05-31
  • 2021-12-24
相关资源
相似解决方案