Thursday, April 05, 2012

"Everything you wanted to know about databinding..." series (Know it, live it, data bind it...)

ScottLogic - Colin Eberhardt- Everything you wanted to know about databinding in WPF, Silverlight and WP7 (Part One)

"OK, so the title is a little ambitious, but there is nothing wrong with setting yourself lofty aims! Because of the depth of this topic I have decided to split this tutorial up into a series of blog posts, each of which explore a different aspect of the binding framework.

I don’t usually write tutorial blog posts and series, preferring instead to develop new controls or novel techniques. However, I really felt this subject needed an in-depth tutorial. Databinding is a fundamental part of the WPF, Silverlight and the Silverlight for Windows Phone 7 frameworks. It is a powerful concept that once mastered allows you to write concise and elegant code. Yet for all its power, it is a little complex and that is my reason for launching into this blog series.

The rough outline for this series is as follows:

  • Part One – Life before binding, INotifyPropertyChanged and creating bindings in code-behind
  • Part Two – The binding markup extensions, the DataContext and path syntax
  • Part Three – Other binding sources, ElementName, TemplatedParent, TemplateBinding
  • Part Four – Value converters
  • Part Five – List binding


Having recently jumped back into the WPF world for some personal utility app building, I'm again humbled on just how little I know (or have to relearn). You all know that if you WPF (or Silverlight or XAML) and you're not data binding, then you're doing it wrong. Code behind needs to be left behind if at all possible. Sure for the uber-simple app's, it's okay. And for the initial prototype, to get something working it's okay (but watch the techdebt), but there comes a time in the app where the complexity will screen for data binding, separation of concerns, some kind of model, like MVVM. You'll know when that time comes, I'm sure. but the key is building it right'er earlier if you can.

Anyway, this looks like a great series and one I'll be following closely.

No comments: