I'm not quite sure if I've got the right grasp on this or not, what I've read seems to agree with what I'm trying to do, however It doesn't seem to be working.
If I add an additional owner to a dependency property of a class, whenever the orig class dp changes, the change should get propagated to the additional owner, correct?
What I have is a custom control, which I want to set a property on, and then on certain objects that are within the custom control data template inherit this property value.
public class Class1: DependencyObject{ public static readonly DependencyProperty LongDayHeadersProperty; public bool LongDayHeaders { get { return (bool)GetValue(LongDayHeadersProperty); } set { SetValue(LongDayHeadersProperty, value); } } static Class1(){ LongDayHeadersProperty = DependencyProperty.Register("LongDayHeaders", typeof(bool), typeof(Class1), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)); } } public class Class2: DependecyObject{ public static readonly DependencyProperty LongDayHeadersProperty; public bool LongDayHeaders{ get{ return(bool)GetValue(LongDayHeadersProperty); } set{ SetValue(LongDayHeadersProperty, value); } } static Class2(){ LongDayHeadersProperty = Class1.LongDayHeadersProperty.AddOwner(typeof(Class2)); } }
But if I assign a DependencyPropertyDescriptor to both properties, it only fires for the Class1 and Class2 doesn't change.
Have I missed something in my understanding?
UPDATE
After some testing, I'm not even sure if my child control is considered a child control within the logical or visual tree. I think it is, but the lack of success leads me to believe otherwise.
There a many class2's which exist in an observable collection of class1. This, to me, makes them childs of class1? But even if I use RegisterAttach on class2, and set the property in class1, it doesn't seem to have any effect?