嗨,有人可以告诉我我是否错过了一些有用的界面吗?还有缺点吗?
对于模型:
IEditableObject
IClonable
INotifyPropertyChanging
、INotifyPropertyChanged
(如果后端有一些模型更新)- ???
对于 ViewModel:
INotifyPropertyChanging
INotifyPropertyChanged
IDataErrorInfo
IDisposable
- ???
对于 View :
- >??? (我听说过
IView (DataContext {set;})
)
最佳答案
是的,您拥有框架本身提供的所有通用接口(interface)。这些应该足以让您成为 MVVM 忍者!
如果您需要其他任何东西,我建议您在需要时创建自己的界面。
关于一般接口(interface),请参阅我回答的相关问题:
I'm worried I'm adding too many interfaces
If I create an
IView
interface, will I ever reference my class by that interface alone? i.e. will there be contexts where I interact with my class purely via the single property that interface exposes?Also, can you consider contexts where you will interact with multiple implementation of this
IView
interface?If the answer to both of these question is "no", then the interface serves very little purpose.
关于c# - MVVM 的通用接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14931463/