summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/VisualElementRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/VisualElementRenderer.cs17
1 files changed, 13 insertions, 4 deletions
diff --git a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
index 5abb809f..d44714be 100644
--- a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
@@ -212,6 +212,12 @@ namespace Xamarin.Forms.Platform.Android
Performance.Stop();
}
+ /// <summary>
+ /// Determines whether the native control is disposed of when this renderer is disposed
+ /// Can be overridden in deriving classes
+ /// </summary>
+ protected virtual bool ManageNativeControlLifetime => true;
+
protected override void Dispose(bool disposing)
{
if ((_flags & VisualElementRendererFlags.Disposed) != 0)
@@ -244,11 +250,14 @@ namespace Xamarin.Forms.Platform.Android
_gestureListener = null;
}
- int count = ChildCount;
- for (var i = 0; i < count; i++)
+ if (ManageNativeControlLifetime)
{
- AView child = GetChildAt(i);
- child.Dispose();
+ int count = ChildCount;
+ for (var i = 0; i < count; i++)
+ {
+ AView child = GetChildAt(i);
+ child.Dispose();
+ }
}
RemoveAllViews();