FrameworkElement.DataContext property is a fundamental part of the XAML data-binding system and allows an object to be associated with a top-level element in the visual tree and then inherited by descendants of that element.
Unfortunately, the Windows Phone SDK does not include a public event for detecting when the
DataContext of a
FrameworkElement is changed. As a workaround, I have included in the downloadable sample code a class named
DataContextChangedListener that uses attached properties to emulate a
DataContextChanged event, which allows you to receive notification when a
FrameworkElement’s data context is changed (see Listing 26.4).
Subscribe method of the
DataContextChangedListener associates ...