diff --git a/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs b/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs index 929f7142bb5..a67190c8316 100644 --- a/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs +++ b/src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs @@ -92,6 +92,7 @@ public void Activate() { if (!_isActive) { + _innerSubscription ??= _binding.Observable.Subscribe(_inner); _isActive = true; PublishNext(); } @@ -102,6 +103,8 @@ public void Deactivate() if (_isActive) { _isActive = false; + _innerSubscription?.Dispose(); + _innerSubscription = null; PublishNext(); } } @@ -148,7 +151,10 @@ void IObserver>.OnNext(BindingValue value) protected override void Subscribed() { - _innerSubscription = _binding.Observable.Subscribe(_inner); + if (_isActive) + { + _innerSubscription = _binding.Observable.Subscribe(_inner); + } } protected override void Unsubscribed()