/// <summary> /// Called to destroy the intellisense popup /// </summary> private void DestroyPopup() { if (_popup != null) { _popup.ListKeyDown -= ListKeyDown; _popup.ListItemDoubleClick -= ListItemDoubleClick; if (_popup.IsOpen) { _popup.IsOpen = false; } _startText = string.Empty; _popup = null; } }
/// <summary> /// Constructor /// </summary> public EditorInstance() { _editor = null; _popup = null; _startText = string.Empty; _editor = new TextBox(); _editor.KeyDown += EditorKeyDown; _editor.TextChanged += EditorTextChanged; _editor.PreviewKeyDown += EditorPreviewKeyDown; _editor.GotFocus += EditorGotFocus; _editor.LostFocus += EditorLostFocus; _editor.Unloaded += EditorUnloaded; }
/// <summary> /// Creates the intellisense popup /// </summary> /// <param name="isSource"></param> private void CreatePopup(List <IntellisenseEntry> isSource) { DestroyPopup(); _popup = new IntellisensePopup { DataContext = isSource, PlacementTarget = _editor, Placement = PlacementMode.Bottom, Width = Math.Max(300, Math.Min(300, _editor.ActualWidth)), Height = 200, }; _popup.ListKeyDown += ListKeyDown; _popup.ListItemDoubleClick += ListItemDoubleClick; _popup.IsOpen = true; }