Binding: WPF vs WinForms
As far as I know, INotifyPropertyChanges was "invented" before WPF. Could someone please explain what is new in WPF that allowed to do different kinds of binding 开发者_开发知识库properties of the control to the properties of objects.
Either this was also available in the WinForms but wasn't so popular due to some reasons? (if yes, what is that reasons)?
Thanks.
In WPF, you can bind not only to objects implementing INotifyPropertyChanged
, but also to dependency objects exposing dependency properties, which are much more flexible than regular properties.
There are also new interfaces for collections :
INotifyCollectionChanged
, which allows collections to send notifications when items are added, deleted or replacedICollectionView
, which defines how a collection is presented to the UI
The WPF binding mechanism is also much more flexible than the Windows Forms bindings... In Windows Forms, you could only say : Bind property X of object A to property Y of object B. There was no DataContext, so you couldn't define relative bindings. You couldn't use complex property paths (e.g. A.X.Items[foo].Bar). All conversions had to be done in event handlers rather than in reusable converters. Bindings could only be defined on controls, whereas in WPF any DependencyObject
can use bindings. And so on...
精彩评论