问题描述
大多数MVVM的例子我也通过合作办过的模型的实现INotifyPropertyChanged,但在的 视图模型实现INotifyPropertyChanged
Most MVVM examples I have worked through have had the Model implement INotifyPropertyChanged, but in Josh Smith's CommandSink example the ViewModel implements INotifyPropertyChanged.
我还是认知放在一起的MVVM的概念,所以我不知道是否:
I'm still cognitively putting together the MVVM concepts, so I don't know if:
- 您必须把INotifyPropertyChanged的在视图模型得到CommandSink工作
- 这只是常态的像差,它并不真正的问题
- 您应该始终有模型实现INotifyPropertyChanged这只是如果这是从一个code例如开发一个应用程序这将予以纠正一个错误
什么都被别人的MVVM项目的经验,你已经工作了?
What have been others' experiences on MVVM projects you have worked on?
推荐答案
我说恰恰相反,我总是把我的 INotifyPropertyChanged的
我的视图模型 - 你真不不想成为像 INotifyPropertyChanged的
相当WPF特定功能,这些东西应该坐在视图模型污染模型。
I'd say quite the opposite, I always put my INotifyPropertyChanged
on my ViewModel - you really don't want to be polluting your model with a fairly WPF specific feature like INotifyPropertyChanged
, that stuff should sit in the ViewModel.
我相信其他人会不同意,但这是我的工作方式。
I'm sure others would disagree, but that's the way I work.
这篇关于在MVVM应视图模型或模式实现INotifyPropertyChanged?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!