ObservableObject或INotifyPropertyChanged的上的ViewModels [英] ObservableObject or INotifyPropertyChanged on ViewModels

查看:406
本文介绍了ObservableObject或INotifyPropertyChanged的上的ViewModels的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,是什么做的的ViewModels 的最好的事情。它是更好地实现接口 INotifyPropertyChanged的 ObservableObject 派生。

I was curious what was the best thing to do with ViewModels. Is it better to implement the interface INotifyPropertyChanged or to derive from ObservableObject.

ObservableObject INotifyPropertyChanged的并做一些像 RaisePropertyChanged枯燥的代码

INotifyPropertyChanged的要求实施的PropertyChanged 事件。

从我的角度来看,似乎更符合逻辑使用 ObservableObject ,但在大多数它们实现本教程的<在他们的视图模型

From my point of view it seems more logical to use ObservableObject, but in most of the tutorial they implement INotifyPropertyChanged interface on their ViewModel.

你是否认为这是为简单起见,还是有一个合乎逻辑的理由?

Do you think it's for the sake of simplicity or there's a logical reason ?

推荐答案

ObservableObject 是Microsoft.Practices.Composite.Presentation的一部分 - 即棱镜。它也被 MVVM光 MVVM基金会

INotifyPropertyChanged的 是System.ComponentModel的一部分 - 也就是说,它的核心库

INotifyPropertyChanged is part of System.ComponentModel - i.e. it's in the core libraries.

所以,如果你是尚未包括棱镜或其他框架我与 INotifyPropertyChanged的坚持之一。似乎有小点,包括它只是为了得到这个类。

So, if you are not already including Prism or one of the other frameworks I'd stick with INotifyPropertyChanged. There seems to be little point in including it just to get this one class.

这篇关于ObservableObject或INotifyPropertyChanged的上的ViewModels的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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