示例#1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var contentElement = this.GetTemplateChild(TextBoxConstants.ContentElementPartName) as ContentControl;

            if (contentElement != null)
            {
                _placeHolder = this.GetTemplateChild(TextBoxConstants.PlaceHolderPartName) as IFrameworkElement;
                _textBoxView = contentElement.GetChildren().FirstOrDefault() as TextBoxView;

                var button = this.GetTemplateChild(TextBoxConstants.DeleteButtonPartName) as Button;
                if (button != null)
                {
                    _deleteButton = new WeakReference <Button>(button);
                }

                if (_textBoxView == null)
                {
                    _textBoxView = new TextBoxView()
                                   .Binding("BindableText", new Data.Binding()
                    {
                        Path           = "Text",
                        RelativeSource = RelativeSource.TemplatedParent,
                        Mode           = BindingMode.TwoWay
                    });

                    contentElement.Content = _textBoxView;
                }

                SetupTextBoxView();

                InitializeProperties();
            }
        }
示例#2
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (AcceptsReturn || TextWrapping != TextWrapping.NoWrap)
                {
                    if (_textBoxView != null && _textBoxView.IsMultiline)
                    {
                        return;
                    }

                    _textBoxView = new TextBoxView(this, isMultiline: true);

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
                else
                {
                    if (_textBoxView != null && !_textBoxView.IsMultiline)
                    {
                        return;
                    }

                    _textBoxView = new TextBoxView(this, isMultiline: false);

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
            }
        }
示例#3
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Ensures we don't keep a reference to a textBoxView that exists in a previous template
            _textBoxView = null;

            _placeHolder    = this.GetTemplateChild(TextBoxConstants.PlaceHolderPartName) as IFrameworkElement;
            _contentElement = this.GetTemplateChild(TextBoxConstants.ContentElementPartName) as ContentControl;

            if (_contentElement is ScrollViewer scrollViewer)
            {
                // We disable scrolling because the inner TextBoxView provides its own scrolling
                scrollViewer.HorizontalScrollMode          = ScrollMode.Disabled;
                scrollViewer.VerticalScrollMode            = ScrollMode.Disabled;
                scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            }

            if (this.GetTemplateChild(TextBoxConstants.DeleteButtonPartName) is Button button)
            {
                _deleteButton = new WeakReference <Button>(button);
            }

            UpdateTextBoxView();
            InitializeProperties();
        }
示例#4
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (_textBoxView is TextBoxView || _textBoxView is SecureTextBoxView)
                {
                    return;
                }

                if (_isPassword)
                {
                    _textBoxView = new SecureTextBoxView(this)
                    {
                        UsesSingleLineMode = true
                    };
                    _revealView = new TextBoxView(this)
                    {
                        UsesSingleLineMode = true
                    };
                    _isSecured = true;
                }
                else
                {
                    _textBoxView = new TextBoxView(this)
                    {
                        UsesSingleLineMode = AcceptsReturn || TextWrapping != TextWrapping.NoWrap
                    };
                }

                _contentElement.Content = _textBoxView;
                _textBoxView.SetTextNative(Text);
                InitializeProperties();
            }
        }
示例#5
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (AcceptsReturn || TextWrapping != TextWrapping.NoWrap)
                {
                    if (_textBoxView != null && _textBoxView.IsMultiline)
                    {
                        return;
                    }

                    _textBoxView = new TextBoxView(this, isMultiline: true)
                                   .Binding("Text", new Data.Binding()
                    {
                        Path   = "Text",
                        Source = this,
                        Mode   = BindingMode.TwoWay
                    });

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
                else
                {
                    if (_textBoxView != null && !_textBoxView.IsMultiline)
                    {
                        return;
                    }

                    _textBoxView = new TextBoxView(this, isMultiline: false)
                                   .Binding("Text", new Data.Binding()
                    {
                        Path   = "Text",
                        Source = this,
                        Mode   = BindingMode.TwoWay
                    });

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
            }
        }
示例#6
0
        private void UpdateTextBoxView()
        {
            if (_textBoxView == null && _contentElement != null)
            {
                _textBoxView = _contentElement.GetChildren().FirstOrDefault() as TextBoxView;

                if (_textBoxView == null)
                {
                    _textBoxView = new TextBoxView(this);

                    _contentElement.Content = _textBoxView;
                    _textBoxView.SetTextNative(Text);

                    _editableFactory = _editableFactory ?? new Factory(WeakReferencePool.RentSelfWeakReference(this));
                    _textBoxView.SetEditableFactory(_editableFactory);
                }

                SetupTextBoxView();
            }
        }
示例#7
0
        private void UpdateTextBoxView()
        {
            if (_textBoxView == null && _contentElement != null)
            {
                _textBoxView = _contentElement.GetChildren().FirstOrDefault() as TextBoxView;

                if (_textBoxView == null)
                {
                    _textBoxView = new TextBoxView()
                                   .Binding("BindableText", new Data.Binding()
                    {
                        Path           = "Text",
                        RelativeSource = RelativeSource.TemplatedParent,
                        Mode           = BindingMode.TwoWay
                    });

                    _contentElement.Content = _textBoxView;
                }

                SetupTextBoxView();
            }
        }
示例#8
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (_textBoxView is TextBoxView || _textBoxView is SecureTextBoxView)
                {
                    return;
                }

                if (_isPassword)
                {
                    _textBoxView = new SecureTextBoxView(this)
                    {
                        UsesSingleLineMode = true, Alignment = TextAlignment.ToNativeTextAlignment()
                    };
                    _revealView = new TextBoxView(this)
                    {
                        UsesSingleLineMode = true, Alignment = TextAlignment.ToNativeTextAlignment()
                    };
                    _isSecured = true;
                }
                else
                {
                    var textWrapping       = TextWrapping;
                    var usesSingleLineMode = !(AcceptsReturn || textWrapping != TextWrapping.NoWrap);
                    _textBoxView = new TextBoxView(this)
                    {
                        UsesSingleLineMode = usesSingleLineMode,
                        LineBreakMode      = textWrapping == TextWrapping.WrapWholeWords ? NSLineBreakMode.ByWordWrapping : NSLineBreakMode.CharWrapping,
                        Alignment          = TextAlignment.ToNativeTextAlignment()
                    };
                }

                _contentElement.Content = _textBoxView;
                _textBoxView.SetTextNative(Text);
                InitializeProperties();
            }
        }
示例#9
0
 public TextBoxInputConnection(TextBoxView targetView, IInputConnection editableInputConnection) : base(targetView, fullEditor: true)
 {
     _textBoxView             = targetView;
     _editableInputConnection = editableInputConnection as BaseInputConnection;
 }