I have a editable dropdown combobox, every thing works fine. But i want that it should show only show the matching items. For example if i type 'A' in it should show items starting with alphabet A.
Below is my Combobox code.
<ComboBox Height="23" HorizontalAlignment="Left" Margin="331,65,0,0" Name="comboBox2" VerticalAlignment="Top" Width="163" IsEditable="True" IsTextSearchEnabled="True" PreviewTextInput="ComboBox_PreviewTextInput"/>
Here is Binding source for Combobox
public void BindComboBox2(ComboBox comboBox2)
{
SqlDataAdapter da = new SqlDataAdapter("Select p_id_pk,p_name,fk_com_id FROM products ", con);
DataSet ds = new DataSet();
da.Fill(ds, "products");
comboBox2.ItemsSource = ds.Tables[0].DefaultView;
comboBox2.DisplayMemberPath = ds.Tables[0].Columns["p_name"].ToString();
comboBox2.SelectedValuePath = ds.Tables[0].Columns["p_id_pk"].ToString();
selected_company = ds.Tables[0].Columns["fk_com_id"].ToString();
}
And here it PreviewTextInput Handler Code
private void ComboBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
comboBox.IsDropDownOpen = true;
}