public object GetValue(DependencyProperty dp)
{
- object val = properties[dp];
+ object val = properties.ContainsKey (dp) ? properties [dp] : null;
return val == null ? dp.DefaultMetadata.DefaultValue : val;
}
public object ReadLocalValue(DependencyProperty dp)
{
- object val = properties[dp];
+ object val = properties.ContainsKey (dp) ? properties [dp] : null;
return val == null ? DependencyProperty.UnsetValue : val;
}
class Y : DependencyObject {
}
+ class DefaultValueTest : DependencyObject {
+ public static readonly DependencyProperty AProperty = DependencyProperty.Register("A", typeof(string), typeof(DefaultValueTest), new PropertyMetadata("defaultValueTest"));
+ }
+
[TestFixture]
public class DependencyObjectTest {
[Test]
Assert.AreEqual(2, count);
}
+ [Test]
+ public void TestDefaultValue()
+ {
+ DefaultValueTest obj = new DefaultValueTest ();
+ Assert.AreEqual (obj.GetValue(DefaultValueTest.AProperty), "defaultValueTest");
+ }
+
}
}