O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharing the Source with DataContext

It’s common for many elements in the same user interface to bind to the same source object (different source properties, but the same source object). For this reason, Binding supports an implicit data source rather than explicitly marking every one with a Source, RelativeSource, or ElementName. This implicit data source is also known as a data context.

To designate a source object as a data context, you find a common parent element and set its DataContext property to the source object. (All FrameworkElements have this DataContext property of type Object.) When the system encounters a Binding without an explicit source object, it traverses up the element tree until it finds a non-null DataContext.

Therefore, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required