Presentation: Data Binding Without INotifyPropertyChanged

How would you create this tree control?

If you were using a traditional event-driven approach, you might handle the ticking of a check box by:

  • Checking all of the child nodes.
  • Walking up the tree to update all parent nodes.
  • Adding the checked option to an observable collection.
  • Adding the price of the checked option to the total price.

Consider the edge cases. The user just checked the last option in a package. You have to remove the individual options and add the package. You have to subtract the individual option prices and add the package price. Or maybe they unchecked one option in a package. Now you have to do the same steps in reverse. And you have to change the parents from solid check marks to intermediate dashes.

Event-driven programming is complex and leads to bugs. If you program using dependency instead, then problems like this become much easier.

Eliminate all PropertyChanged events from your code. Replace them with dependency tracking. Download the slides, the option tree demo, and the contact list demo.