Browse Source

Fixed metadata overrides not being able to add coercion to a property which didn't already have it

pull/10617/head
Tom Edwards 4 years ago
parent
commit
38516e3768
  1. 2
      src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs
  2. 14
      src/Avalonia.Base/StyledProperty.cs

2
src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs

@ -31,7 +31,7 @@ namespace Avalonia.PropertyStore
var value = inherited is null ? _metadata.DefaultValue : inherited.Value;
if (property.HasCoercion && _metadata.CoerceValue is { } coerce)
if (_metadata.CoerceValue is { } coerce)
{
_uncommon = new()
{

14
src/Avalonia.Base/StyledProperty.cs

@ -34,7 +34,6 @@ namespace Avalonia
{
Inherits = inherits;
ValidateValue = validate;
HasCoercion |= metadata.CoerceValue != null;
if (validate?.Invoke(metadata.DefaultValue) == false)
{
@ -48,12 +47,6 @@ namespace Avalonia
/// </summary>
public Func<TValue, bool>? ValidateValue { get; }
/// <summary>
/// Gets a value indicating whether this property has any value coercion callbacks defined
/// in its metadata.
/// </summary>
internal bool HasCoercion { get; private set; }
/// <summary>
/// Registers the property on another type.
/// </summary>
@ -130,10 +123,7 @@ namespace Avalonia
/// </summary>
/// <typeparam name="T">The type.</typeparam>
/// <param name="metadata">The metadata.</param>
public void OverrideMetadata<T>(StyledPropertyMetadata<TValue> metadata) where T : AvaloniaObject
{
base.OverrideMetadata(typeof(T), metadata);
}
public void OverrideMetadata<T>(StyledPropertyMetadata<TValue> metadata) where T : AvaloniaObject => OverrideMetadata(typeof(T), metadata);
/// <summary>
/// Overrides the metadata for the property on the specified type.
@ -151,8 +141,6 @@ namespace Avalonia
}
}
HasCoercion |= metadata.CoerceValue != null;
base.OverrideMetadata(type, metadata);
}

Loading…
Cancel
Save