protected override void OnTextChanged(TextChangedEventArgs e) { base.OnTextChanged(e); Decorations.Clear(); if (!textChangedEnable) { return; } if (isPasted) { isPasted = false; return; } foreach (var change in e.Changes) { if (popup.IsOpen) { for (int i = 0; i < change.AddedLength; i++) { if (!char.IsLetterOrDigit(Text, change.Offset + i)) { popup.IsOpen = false; return; } } } if (!popup.IsOpen && change.AddedLength > 0 && (change.Offset <= 0 || !char.IsLetterOrDigit(Text, change.Offset - 1))) { popup.Input = string.Empty; popup.Offset = change.Offset; popup.IsOpen = true; popup.ListBox.SelectedIndex = 0; FixPopupPosition(change.Offset); } } if (popup.IsOpen) { int inputlast; for (inputlast = popup.Offset; inputlast < Text.Length && char.IsLetterOrDigit(Text[inputlast]); inputlast++) { ; } if (inputlast > popup.Offset) { popup.Input = Text.Substring(popup.Offset, inputlast - popup.Offset); } else { popup.IsOpen = false; } } }