8.2. Binding to Objects That Aren't Elements
So far, you've focused on adding bindings that link two elements. But in data-driven applications, it's more common to create binding expressions that draw their data from a nonvisual object. The only requirement is that the information you want to display must be stored in public properties. The WPF data binding infrastructure won't pick up private information or public fields.
When binding to an object that isn't an element, you need to give up the Binding.ElementName property and use one of the following properties instead:
Source. This is a reference that points to the source object—in other words, the object that's supplying the data.
RelativeSource. This points to the source object using a RelativeSource ...
Get Pro WPF in C# 2010: Windows Presentation Foundation in .NET 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.