diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs index 9252133c86b..311d85941ec 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependentList.cs @@ -126,7 +126,7 @@ private void CleanUpDeadWeakReferences() } } - internal struct Dependent + internal struct Dependent : IEquatable { private DependencyProperty _DP; private WeakReference _wrDO; @@ -178,14 +178,14 @@ public Expression Expr return (Expression)_wrEX.Target; } } - + public override bool Equals(object o) { - if(! (o is Dependent)) - return false; - - Dependent d = (Dependent)o; - + return o is Dependent d && Equals(d); + } + + public bool Equals(Dependent d) + { // Not equal to Dead values. // This is assuming that at least one of the compared items is live. // This assumtion comes from knowing that Equal is used by FrugalList.Remove()