protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null && _textfield != null)
            {
                _textfield.EditingChanged         -= EditingChanged;
                _textfield.OnDeleteBackward       -= OnDeleteBackward;
                _textfield.EditingDidEnd          -= EditingDidEnd;
                _textfield.EditingDidBegin        -= EditingDidBegin;
                _textfield.ShouldChangeCharacters -= ShouldChangeCharacters;

                _textfield.Dispose();
                _selectedTextRangeObserver?.Dispose();
                _textfield = null;
            }
            if (Control is null || e.NewElement is null)
            {
                return;
            }

            _element = (CustomEntry)e.NewElement;

            if (_element.BorderColor == Color.Default)
            {
                return;
            }

            _textfield = new UIBackwardsTextField();
            _textfield.EditingChanged         += EditingChanged;
            _textfield.OnDeleteBackward       += OnDeleteBackward;
            _textfield.EditingDidEnd          += EditingDidEnd;
            _textfield.EditingDidBegin        += EditingDidBegin;
            _textfield.ShouldReturn            = OnShouldReturn;
            _textfield.ShouldChangeCharacters += ShouldChangeCharacters;

            // When we set the control text, it triggers the UpdateCursorFromControl event, which updates CursorPosition and SelectionLength;
            // These one-time-use variables will let us initialize a CursorPosition and SelectionLength via ctor/xaml/etc.
            _cursorPositionChangePending  = Element.IsSet(Entry.CursorPositionProperty);
            _selectionLengthChangePending = Element.IsSet(Entry.SelectionLengthProperty);

            SetNativeControl(_textfield);

            //Reupdate properties as when set native control all set up is gone
            Control.Font = _element.ToUIFont();
            Control.ApplyKeyboard(_element.Keyboard);
            Control.ReloadInputViews();
            Control.TextAlignment     = _element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)_element).EffectiveFlowDirection);
            Control.VerticalAlignment = _element.VerticalTextAlignment.ToNativeTextAlignment();
            Control.TextColor         = _element.TextColor.ToUIColor();

            SetupBorder();

            var formatted = (FormattedString)Element.Placeholder;

            if (formatted != null)
            {
                var targetColor = Element.PlaceholderColor;
                var color       = targetColor.IsDefault ? _defaultPlaceholderColor : targetColor;
                UpdateAttributedPlaceholder(formatted.ToAttributed(Element, color));
                UpdateAttributedPlaceholder(Control.AttributedPlaceholder.AddCharacterSpacing(Element.Placeholder, Element.CharacterSpacing));
            }
        }