protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.OldElement == null) { AButton button = Control; if (button == null) { button = CreateNativeControl(); button.SetOnClickListener(ButtonClickListener.Instance.Value); button.SetOnTouchListener(ButtonTouchListener.Instance.Value); button.Tag = this; SetNativeControl(button); var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(button.TextColors, useLegacyColorManagement); button.AddOnAttachStateChangeListener(this); } } if (_backgroundTracker == null) { _backgroundTracker = new ButtonBackgroundTracker(Element, Control); } else { _backgroundTracker.Button = e.NewElement; } UpdateAll(); }
protected override void Dispose(bool disposing) { if (_isDisposed) { return; } _isDisposed = true; if (disposing) { _backgroundTracker?.Dispose(); _backgroundTracker = null; } base.Dispose(disposing); }