diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-09-27 12:02:12 -0600 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-09-27 11:02:12 -0700 |
commit | f252238fec90d8f71b49e35212275b9e588964e3 (patch) | |
tree | a23889fa5716f164dd8cb344425a67d32f4d9534 /Xamarin.Forms.Core/BindingExpression.cs | |
parent | 53e1d99a751e7a9cb8ae3f67ac8f3630b2aea398 (diff) | |
download | xamarin-forms-f252238fec90d8f71b49e35212275b9e588964e3.tar.gz xamarin-forms-f252238fec90d8f71b49e35212275b9e588964e3.tar.bz2 xamarin-forms-f252238fec90d8f71b49e35212275b9e588964e3.zip |
Don't unsubscribe/resubscribe the listener to the same INPC (#384)
Diffstat (limited to 'Xamarin.Forms.Core/BindingExpression.cs')
-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); |