diff --git a/src/Avalonia.Base/PropertyStore/ValueFrame.cs b/src/Avalonia.Base/PropertyStore/ValueFrame.cs index c5cb18806d..e88affab3c 100644 --- a/src/Avalonia.Base/PropertyStore/ValueFrame.cs +++ b/src/Avalonia.Base/PropertyStore/ValueFrame.cs @@ -37,9 +37,8 @@ namespace Avalonia.PropertyStore [NotNullWhen(true)] out IValueEntry? entry, out bool activeChanged) { - if (_index.TryGetValue(property, out entry) && - GetIsActive(out activeChanged)) - return true; + if (_index.TryGetValue(property, out entry)) + return GetIsActive(out activeChanged); activeChanged = false; return false; } diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index d917d73fd2..eb97009355 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -787,30 +787,28 @@ namespace Avalonia.PropertyStore { var frame = _frames[i]; var priority = frame.Priority; + var foundEntry = frame.TryGetEntryIfActive(property, out var entry, out var activeChanged); + + // If the active state of the frame has changed since the last read, and + // the frame holds multiple values then we need to re-evaluate the + // effective values of all properties. + if (activeChanged && frame.EntryCount > 1) + { + ReevaluateEffectiveValues(); + return; + } - if (frame.TryGetEntryIfActive(property, out var entry, out var activeChanged)) + if (foundEntry && entry!.HasValue) { - // If The active state of the frame has changed since the last read, and - // the frame holds multiple values then we need to re-evaluate the - // effective values of all properties. - if (activeChanged && frame.EntryCount > 1) + if (current is not null) { - ReevaluateEffectiveValues(); - return; + current.SetAndRaise(this, entry, priority); } - - if (entry.HasValue) + else { - if (current is not null) - { - current.SetAndRaise(this, entry, priority); - } - else - { - current = property.CreateEffectiveValue(Owner); - AddEffectiveValue(property, current); - current.SetAndRaise(this, entry, priority); - } + current = property.CreateEffectiveValue(Owner); + AddEffectiveValue(property, current); + current.SetAndRaise(this, entry, priority); } }