예제 #1
0
        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();
        }
예제 #2
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            if (disposing)
            {
                _backgroundTracker?.Dispose();
                _backgroundTracker = null;
            }

            base.Dispose(disposing);
        }