views:

253

answers:

4

When doing databinding does one have to implement INotifyPropertyChanged on the datacontext in WPF?

+4  A: 

No. If you don't intend for your object's properties to change, or you don't mind if the UI doesn't reflect those changes, there's no reason to implement INotifyPropertyChanged.

Further, if your object derives from DependencyObject and its properties are dependency properties, data binding will work without INotifyPropertyChanged.

Matt Hamilton
but my object's properties do change and I do mind when my UI doesn't reflect those changes. So which is better to use, INotifyPropertyChanged or dependency object?
Tony
INotifyPropertyChanged is a bit simpler IMHO, and doesn't require you to derive from a certain class, so you have the option of keeping your own class hierarchy.
Matt Hamilton
@Matt I agree. INotifyPropertyChanged is simpler to implement.
Tony
+1  A: 

This one has been answered on SO before here

Leigh Shayler
A: 

If you are interested in a comparison between INotifyPropertyChanged and DependencyProperties you can find a good article here.
In general, if the object supports DependencyProperties, try to avoid INotifyPropertyChanged.

Maurizio Reginelli
A: 

Also, if you are working with ObservalbeCollections, INotifyPropertyChanged is implemented in it, if i'm not mistaken

djerry