Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 301
Budda Avatar asked Jan 21 '10 15:01

Budda


1 Answers

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 replaced
  • ICollectionView, 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...

like image 122
Thomas Levesque Avatar answered Sep 30 '22 07:09

Thomas Levesque