protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { base.OnElementChanged(e); if (e.OldElement != null && _drawableEnabled) { _drawableEnabled = false; _backgroundDrawable.Reset(); _backgroundDrawable = null; } UpdateDrawable(); }
protected override void Dispose(bool disposing) { if (disposing) { if (_backgroundDrawable != null) { _backgroundDrawable.Dispose(); _backgroundDrawable = null; } } base.Dispose(disposing); }
private void UpdateDrawable() { if (Element.BackgroundColor == Color.Default) { if (!_drawableEnabled) { return; } if (_defaultDrawable != null) { Control.SetBackground(_defaultDrawable); } _drawableEnabled = false; } else { if (_backgroundDrawable == null) { _backgroundDrawable = new ButtonDrawable(); } _backgroundDrawable.Button = Element; if (_drawableEnabled) { return; } if (_defaultDrawable == null) { _defaultDrawable = Control.Background; } Control.SetBackground(_backgroundDrawable.GetDrawable()); _drawableEnabled = true; } Control.Invalidate(); }