From f252238fec90d8f71b49e35212275b9e588964e3 Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Tue, 27 Sep 2016 12:02:12 -0600 Subject: [PATCH] Don't unsubscribe/resubscribe the listener to the same INPC (#384) --- Xamarin.Forms.Core/BindingExpression.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Core/BindingExpression.cs b/Xamarin.Forms.Core/BindingExpression.cs index 5ce8cd8..71ba051 100644 --- a/Xamarin.Forms.Core/BindingExpression.cs +++ b/Xamarin.Forms.Core/BindingExpression.cs @@ -409,6 +409,7 @@ namespace Xamarin.Forms class WeakPropertyChangedProxy { WeakReference _source, _listener; + internal WeakReference Source => _source; public WeakPropertyChangedProxy(INotifyPropertyChanged source, PropertyChangedEventHandler listener) { @@ -470,7 +471,13 @@ namespace Xamarin.Forms public void Subscribe(INotifyPropertyChanged handler) { - // If we're reapplying, we don't want to double subscribe + if (ReferenceEquals(handler, _listener?.Source?.Target)) + { + // Already subscribed + return; + } + + // Clear out the old subscription if necessary Unsubscribe(); _listener = new WeakPropertyChangedProxy(handler, _changeHandler); -- 2.7.4