I need an autocomplete combobox for WPF C#. I\'ve tried several approaches but nothing works. For example I\'ve tried a combobox:
In XAML you should set IsEditable=True and add handler for PreviewKeyDown event:
private void ComboBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
var cmb = (ComboBox)sender;
cmb.IsDropDownOpen = true;
var textbox = cmb.Template.FindName("PART_EditableTextBox", cmb) as TextBox;
cmb.ItemsSource = CurrentStorage.Organisations.Where(p => string.IsNullOrEmpty(cmb.Text) || p.Name.ToLower().Contains(textbox.Text.ToLower())).ToList();
}