From 60422d621ba8cb0023730f745224b0b1d55b8916 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 15 Nov 2019 09:31:07 +0100 Subject: [PATCH] Handle GetBindingObservable(). --- .../AvaloniaPropertyBindingObservable.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/Reactive/AvaloniaPropertyBindingObservable.cs b/src/Avalonia.Base/Reactive/AvaloniaPropertyBindingObservable.cs index d157a00fee..9501640626 100644 --- a/src/Avalonia.Base/Reactive/AvaloniaPropertyBindingObservable.cs +++ b/src/Avalonia.Base/Reactive/AvaloniaPropertyBindingObservable.cs @@ -48,13 +48,25 @@ namespace Avalonia.Reactive { if (e.Property == _property) { - var typedArgs = (AvaloniaPropertyChangedEventArgs)e; - var newValue = e.Sender.GetValue(typedArgs.Property); + if (e is AvaloniaPropertyChangedEventArgs typedArgs) + { + var newValue = e.Sender.GetValue(typedArgs.Property); - if (!typedArgs.OldValue.HasValue || !EqualityComparer.Default.Equals(newValue, _value)) + if (!typedArgs.OldValue.HasValue || !EqualityComparer.Default.Equals(newValue, _value)) + { + _value = newValue; + PublishNext(_value); + } + } + else { - _value = newValue; - PublishNext(_value); + var newValue = e.Sender.GetValue(e.Property); + + if (!Equals(newValue, _value)) + { + _value = (T)newValue; + PublishNext(_value); + } } } }