Browse Source

Move default value handling to AvaloniaObject.

pull/1703/head
Steven Kirk 8 years ago
parent
commit
cbc0755098
  1. 13
      src/Avalonia.Base/AvaloniaObject.cs
  2. 5
      src/Avalonia.Base/ValueStore.cs

13
src/Avalonia.Base/AvaloniaObject.cs

@ -225,7 +225,14 @@ namespace Avalonia
}
else if (_values != null)
{
return _values.GetValue(property);
var result = _values.GetValue(property);
if (result == AvaloniaProperty.UnsetValue)
{
result = GetDefaultValue(property);
}
return result;
}
else
{
@ -645,8 +652,8 @@ namespace Avalonia
/// <returns>The default value.</returns>
internal object GetDefaultValue(AvaloniaProperty property)
{
if (property.Inherits && InheritanceParent is AvaloniaObject aobj && aobj._values != null)
return aobj._values.GetValue(property);
if (property.Inherits && InheritanceParent is AvaloniaObject aobj)
return aobj.GetValue(property);
return ((IStyledPropertyAccessor) property).GetDefaultValue(GetType());
}

5
src/Avalonia.Base/ValueStore.cs

@ -110,11 +110,6 @@ namespace Avalonia
result = (value is PriorityValue priorityValue) ? priorityValue.Value : value;
}
if (result == AvaloniaProperty.UnsetValue)
{
result = _owner.GetDefaultValue(property);
}
return result;
}

Loading…
Cancel
Save