MVVM模型是一个单独的类库,如何实现inotifypropertychanged和inotifydataerrorinfo? [英] Model of MVVM is a separate class library, how to implement inotifypropertychanged and inotifydataerrorinfo?

查看:69
本文介绍了MVVM模型是一个单独的类库,如何实现inotifypropertychanged和inotifydataerrorinfo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单独的图层中有DataTransfterObjects(DTO),所以我认为在wpf应用程序中不需要模型。我在应用程序中只有View和viewmodel。



一切正常,但问题是如何在DTO中实现INotifyPropertyChanged和INotifyDataErrorInfo。如何使用这两个接口的功能?如何进行验证?



我的尝试:



我有三个BLL,DAL和DTO类库,wpf应用程序只有ViewModel和View,我在Wpf应用程序中使用DTO作为模型。现在,如果我实现IDataErrorInfo进行验证,那么它是否可行或者我必须做更多工作?

I have DataTransfterObjects (DTO) in separate layer so I think no need of model in wpf application. I only have View and viewmodel in the application.

Everything works fine but issue is how to implement INotifyPropertyChanged and INotifyDataErrorInfo in DTO. How to use functionalities of these two interfaces? How to make validations?

What I have tried:

I have three class libraries of BLL, DAL and DTO and a wpf application have ViewModel and View only, I am using DTO as a model in the wpf application. Now If I implement IDataErrorInfo for validations then will it work or I have to do more?

推荐答案

更改通知(例如,对于wpf中的绑定)应该在viewmodel中实现 - 让模型独自......这将是MVVM - 我并不是说你不能拥有实现这些接口的模型类 - 但在MVVM中,这将是ViewModel的明确责任
Change notifications (e.g. for bindings in wpf) should be implemented in a viewmodel - let the model alone... This would be MVVM - I don't mean you can not have a model-classes implemening these Interfaces - but in MVVM this would be a clear responsibillity of the ViewModel


这篇关于MVVM模型是一个单独的类库,如何实现inotifypropertychanged和inotifydataerrorinfo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆