private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info) { comboBox.DataContext = new StringListViewModel(); comboBox.TextChanged += (s, e) => info.SearchFunction(); comboBox.KeyDown += (s, e) => { if (e.Key == Key.Return || e.Key == Key.Enter) { info.SearchFunction(); } }; comboBox.PrePreviewKeyDown += (s, e) => { if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down) { FileTreeView.Focus(); e.Handled = true; } }; }
private void InitComboBox(EditableComboBox comboBox, ComboBoxInfo info) { comboBox.DataContext = new StringListViewModel(info.InitialItems); comboBox.TextChanged += (s, e) => { info.TextChanged(comboBox.Text); info.SearchFunction(false); }; comboBox.KeyDown += (s, e) => { if ((e.KeyboardDevice.Modifiers == ModifierKeys.None) && (e.Key == Key.Return || e.Key == Key.Enter)) { info.SearchFunction(true); } }; if (info.PreviousElement != null) { comboBox.PrePreviewKeyDown += (s, e) => { if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Up) { if (!comboBox.IsDropDownOpen) { info.PreviousElement.Focus(); e.Handled = true; } } }; } if (info.NextElement != null) { comboBox.PrePreviewKeyDown += (s, e) => { if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down) { if (!comboBox.IsDropDownOpen) { info.NextElement.Focus(); e.Handled = true; } } }; } }