From 8eefb6d6fd9cf65dfc9b29bbb23c24189a5d41cb Mon Sep 17 00:00:00 2001 From: beto rodriguez Date: Tue, 15 Oct 2024 08:25:39 -0600 Subject: [PATCH] also related to #1614 --- src/LiveChartsCore/Kernel/ChartElement.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/LiveChartsCore/Kernel/ChartElement.cs b/src/LiveChartsCore/Kernel/ChartElement.cs index d42f2f974..14ab5160c 100644 --- a/src/LiveChartsCore/Kernel/ChartElement.cs +++ b/src/LiveChartsCore/Kernel/ChartElement.cs @@ -97,7 +97,11 @@ protected virtual void SetPaintProperty( bool isStroke = false, [CallerMemberName] string? propertyName = null) { - if (value == reference) return; + // The null check is intentional. + // we need to allow nulls to go further this if + // OnPropertyChanged needs to be called + // to detect whether the user set the null value. + if (value is not null && value == reference) return; if (propertyName is null) throw new ArgumentNullException(nameof(propertyName)); if (!CanSetProperty(propertyName)) return; @@ -127,7 +131,11 @@ protected virtual void SetProperty( T value, [CallerMemberName] string? propertyName = null) { - if (Equals(value, reference)) return; + // The null check is intentional. + // we need to allow nulls to go further this if + // OnPropertyChanged needs to be called + // to detect whether the user set the null value. + if (value is not null && value.Equals(reference)) return; if (propertyName is null) throw new ArgumentNullException(nameof(propertyName)); if (!CanSetProperty(propertyName)) return;