public void When_SimpleInheritance_Early() { var root = new Grid(); var child1 = new Grid(); Assert.AreEqual(0, MyAttachedPropType.GetMyProperty(child1)); root.Children.Add(child1); MyAttachedPropType.SetMyProperty(root, 42); Assert.AreEqual(42, MyAttachedPropType.GetMyProperty(child1)); }
public void When_SimpleInheritance_Early_Event() { var root = new Grid(); var child1 = new Grid(); int propagatedValue = -1; child1.RegisterPropertyChangedCallback( MyAttachedPropType.MyPropertyProperty, (s, e) => { propagatedValue = MyAttachedPropType.GetMyProperty(child1); } ); Assert.AreEqual(-1, propagatedValue); MyAttachedPropType.SetMyProperty(root, 42); root.Children.Add(child1); Assert.AreEqual(42, MyAttachedPropType.GetMyProperty(child1)); Assert.AreEqual(42, propagatedValue); }