summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/VisualElement.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-06 13:15:32 +0100
committerRui Marinho <me@ruimarinho.net>2016-12-06 12:15:32 +0000
commit20e2e12dce2f81b92e8682f128cd81e08469f485 (patch)
tree965f0715dc24af3c0d0bd17740da9d962ed12927 /Xamarin.Forms.Core/VisualElement.cs
parent10c65d035869fdc587f6ddddc0d472033af61ee6 (diff)
downloadxamarin-forms-20e2e12dce2f81b92e8682f128cd81e08469f485.tar.gz
xamarin-forms-20e2e12dce2f81b92e8682f128cd81e08469f485.tar.bz2
xamarin-forms-20e2e12dce2f81b92e8682f128cd81e08469f485.zip
[C] detach Behaviors and Triggers on VE finalization (#555)
* [C] detach Behaviors and Triggers on VE finalization * update docs
Diffstat (limited to 'Xamarin.Forms.Core/VisualElement.cs')
-rw-r--r--Xamarin.Forms.Core/VisualElement.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/VisualElement.cs b/Xamarin.Forms.Core/VisualElement.cs
index 053ddb0a..cff1eb10 100644
--- a/Xamarin.Forms.Core/VisualElement.cs
+++ b/Xamarin.Forms.Core/VisualElement.cs
@@ -781,5 +781,18 @@ namespace Xamarin.Forms
public bool Result { get; set; }
}
+
+ ~VisualElement()
+ {
+ if (!GetIsDefault(BehaviorsProperty)) {
+ var behaviors = GetValue(BehaviorsProperty) as AttachedCollection<Behavior>;
+ behaviors.DetachFrom(this);
+ }
+
+ if (!GetIsDefault(TriggersProperty)) {
+ var triggers = GetValue(TriggersProperty) as AttachedCollection<Trigger>;
+ triggers.DetachFrom(this);
+ }
+ }
}
} \ No newline at end of file