protected override void Dispose(bool disposing) { if (CheckFlagsForDisposed()) { return; } _flags |= VisualElementRendererFlags.Disposed; if (disposing) { SetOnClickListener(null); SetOnTouchListener(null); EffectUtilities.UnregisterEffectControlProvider(this, Element); if (Element != null) { Element.PropertyChanged -= _propertyChangeHandler; } if (Tracker != null) { Tracker.Dispose(); Tracker = null; } if (_packager != null) { _packager.Dispose(); _packager = null; } if (ManageNativeControlLifetime) { while (ChildCount > 0) { AView child = GetChildAt(0); child.RemoveFromParent(); child.Dispose(); } } if (Element != null) { if (Platform.GetRenderer(Element) == this) { Platform.SetRenderer(Element, null); } Element = null; } } base.Dispose(disposing); }