diff options
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r-- | Xamarin.Forms.Core/BindingExpression.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Xamarin.Forms.Core/BindingExpression.cs b/Xamarin.Forms.Core/BindingExpression.cs index 5ce8cd87..71ba0512 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); |