diff options
author | E.Z. Hart <hartez@gmail.com> | 2016-09-26 18:09:58 -0600 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-09-27 11:02:54 -0700 |
commit | 1a86ca598e7af954a584226b1a7761ef3675d39e (patch) | |
tree | 75c0e5073cb342dcceac07c3782ca727dc9a9927 | |
parent | d9a550b408169580ae2bd0e5634d9fe2f46a8ccc (diff) | |
download | xamarin-forms-1a86ca598e7af954a584226b1a7761ef3675d39e.tar.gz xamarin-forms-1a86ca598e7af954a584226b1a7761ef3675d39e.tar.bz2 xamarin-forms-1a86ca598e7af954a584226b1a7761ef3675d39e.zip |
Don't unsubscribe/resubscribe the listener to the same INPC
-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); |