private void ExpressionEditor_KeyUp(object sender, KeyEventArgs e) { //bool showPropertyMethodList = false; //bool rightctrlSpace = false; bool ctrlSpace = false; bool dot = false; if (e.Key == Key.Space && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { ctrlSpace = true; } if (e.Key == Key.OemPeriod && (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))) { dot = true; } if (dot || ctrlSpace) { FormulaAutoCompleteKeyType keyType; string theWord = ""; if (ctrlSpace && ExpressionEditor.ExpressionText == "") { keyType = FormulaAutoCompleteKeyType.EmptyLeftCtrlSpace; } else { DocumentPosition pos = new DocumentPosition(richTextBox.Document); pos.MoveToPosition(richTextBox.Document.CaretPosition); pos.MoveToPrevious(); var str = (richTextBox.Document.CaretPosition.GetCurrentWord()); if (str == Environment.NewLine) { theWord = GetPreviousWord(richTextBox.Document, GetPreviousWord(richTextBox.Document, richTextBox.Document.CaretPosition).Item1).Item2; } else { theWord = GetPreviousWord(richTextBox.Document, richTextBox.Document.CaretPosition).Item2; } if (dot) { keyType = FormulaAutoCompleteKeyType.DotOnly; } else { //leftctrlSpace if (pos.GetCurrentWord() == ".") { keyType = FormulaAutoCompleteKeyType.AfterDotLeftCtrlSpace; } else { keyType = FormulaAutoCompleteKeyType.InTextLeftControlSpace; } } } ShowAutoComplete(keyType, theWord); } else if (e.Key != Key.LeftCtrl && e.Key != Key.LeftAlt) { //myPopup.IsOpen = false; } }