Thursday, March 31, 2011

Binding Sources

The syntax of Binding is a source of much confusion to a lot of people (pun intended). But it is really not that hard. Especially once you look at all the possible sources:

  • ElementName (based on an element name present in the scope)
  • RelativeSource (based on a logical tree walk)
  • Source (based on resources)
  • If none of these properties is specified the path will be on the DataContext
Of course if no path is specified then you are binding directly to the source. 

In any case feel free to use the VisualStudio / Expression Blend databinding dialog to have software generate the syntax for you. 

Easy isn't it?