Ejemplo n.º 1
0
        private void InsertText()
        {
            var filter       = FilterText ?? string.Empty;
            var insertText   = filter + FilteredItems.ElementAt(AutoCompleteBox.SelectedIndex).Substring(filter.Length);
            var currentCaret = AssociatedObject.CaretIndex;

            string newText = AssociatedObject.Text;

            newText       = newText.Remove(currentCaret - filter.Length, filter.Length);
            currentCaret -= filter.Length;
            newText       = newText.Insert(currentCaret, insertText);

            AssociatedObject.Text       = newText;
            AssociatedObject.CaretIndex = currentCaret + insertText.Length;
        }