Пример #1
0
 public void CursorToEnd(bool closeDropDown = true)
 {
     EditableTextBox.Select(this.EditableTextBox.Text.Length, 0);
     if (closeDropDown)
     {
         IsDropDownOpen = false;
     }
 }
        private void OnTextChanged(object sender, EventArgs e)
        {
            if (!IsTextSearchEnabled && _silenceEvents == 0)
            {
                RefreshFilter();

                if (Text.Length > 0)
                {
                    foreach (var item in CollectionViewSource.GetDefaultView(ItemsSource))
                    {
                        var itemText = GetItemText(item);
                        int text = itemText.Length, prefix = Text.Length;
                        SelectedItem = item;

                        _silenceEvents++;
                        EditableTextBox.Text = itemText;
                        EditableTextBox.Select(prefix, text - prefix);
                        _silenceEvents--;
                        break;
                    }
                }
            }
        }
        private void OnTextChanged(object sender, EventArgs e)
        {
            if (!_textSaved)
            {
                _savedText = Text;
                _textSaved = true;
            }

            if (IsTextSearchEnabled || _silenceEvents != 0)
            {
                return;
            }

            RefreshFilter();

            // Manually simulate the automatic selection that would have been
            // available if the IsTextSearchEnabled dependency property was set.
            if (Text.Length <= 0)
            {
                return;
            }
            var prefix = Text.Length;

            _collView = CollectionViewSource.GetDefaultView(ItemsSource);
            foreach (var item in _collView)
            {
                var text = item.ToString().Length;
                SelectedItem = item;

                SilenceEvents();
                EditableTextBox.Text = item.ToString();
                EditableTextBox.Select(prefix, text - prefix);
                UnSilenceEvents();
                break;
            }
        }