/// <summary> /// Handles changes to the DataContextPiggyBack property. /// </summary> private static void OnDataContextPiggyBackChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FrameworkElement targetElement = d as FrameworkElement; // whenever the targeElement DataContext is changed, copy the updated property // value to our MultiBinding. MultiBindings relay = GetMultiBindings(targetElement); relay.SetDataContext(targetElement.DataContext); }
/// <summary> /// Invoked when the MultiBinding property is set on a framework element /// </summary> private static void OnMultiBindingsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { FrameworkElement targetElement = depObj as FrameworkElement; // bind the target elements DataContext, to our DataContextPiggyBack property // this allows us to get property changed events when the targetElement // DataContext changes targetElement.SetBinding(DataContextPiggyBackProperty, new Binding()); MultiBindings bindings = GetMultiBindings(targetElement); bindings.Initialize(targetElement); }
public static void SetMultiBindings(DependencyObject obj, MultiBindings value) { obj.SetValue(MultiBindingsProperty, value); }