コード例 #1
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;

            var scrollViewer = _contentElement as ScrollViewer;

            if (scrollViewer != null)
            {
                // We disable horizontal scrolling because the inner SingleLineTextBoxView provides its own horizontal scrolling
                scrollViewer.HorizontalScrollMode = ScrollMode.Disabled;
            }

            var button = this.GetTemplateChild(TextBoxConstants.DeleteButtonPartName) as Button;

            if (button != null)
            {
                _deleteButton = new WeakReference <Button>(button);
            }

            UpdateTextBoxView();
            InitializeProperties();
        }
コード例 #2
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (AcceptsReturn || TextWrapping != TextWrapping.NoWrap)
                {
                    if (_textBoxView is MultilineTextBoxView)
                    {
                        return;
                    }

                    _textBoxView = new MultilineTextBoxView(this);

                    _contentElement.Content = _textBoxView;
                    _textBoxView.SetTextNative(Text);
                    InitializeProperties();
                }
                else
                {
                    if (_textBoxView is SinglelineTextBoxView)
                    {
                        return;
                    }

                    _textBoxView = new SinglelineTextBoxView(this);

                    _contentElement.Content = _textBoxView;
                    _textBoxView.SetTextNative(Text);
                    InitializeProperties();
                }
            }
        }
コード例 #3
0
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (_textBoxView is TextBoxView || _textBoxView is SecureTextBoxView)
                {
                    return;
                }

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

                _contentElement.Content = _textBoxView;
                _textBoxView.SetTextNative(Text);
                InitializeProperties();
            }
        }
コード例 #4
0
ファイル: TextBox.iOS.cs プロジェクト: nepronen/Uno
        private void UpdateTextBoxView()
        {
            if (_contentElement != null)
            {
                if (AcceptsReturn || TextWrapping != TextWrapping.NoWrap)
                {
                    if (_textBoxView is MultilineTextBoxView)
                    {
                        return;
                    }

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

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
                else
                {
                    if (_textBoxView is SinglelineTextBoxView)
                    {
                        return;
                    }

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

                    _contentElement.Content = _textBoxView;
                    InitializeProperties();
                }
            }
        }
コード例 #5
0
ファイル: TextBox.macOS.cs プロジェクト: Robert-Louis/Uno
        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();
            }
        }