WPF ComboBox 模糊查詢+下拉自動展開時設置:
xml設置ComboBox屬性 IsEditable="True",IsTextSearchEnabled="False",
模糊查詢使用鍵盤事件如 KeyUp查詢結果刷新下列選項
private void comboBox_KeyUp(object sender, KeyEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
this.ViewModel.UpdateComboBoxItems(comboBox.Text); //刷新下拉選項
if (this.ViewModel.ComboBoxItems.Count > 0)
comboBox.IsDropDownOpen = true;
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
textBox.SelectionStart = textBox.Text.Length;
}