Basic Core Features in WPF AutoComplete (Classic)

5 May 20211 minute to read

AutoComplete supports basic core features which are listed as follows.

  • SelectedIndex— Used to set and get the index of the selected item.
  • SelectedItem—Used to get which item of the AutoComplete has been selected.
  • SelectedValue—Used to get the value of the selected item, the value of the SelectedValue property will be set based on the value of the SelectedValuePath property.
  • SelectedValuePath—Used to set the value of the SelectedValue property of the AutoComplete.
  • DisplayMemberPath—Used to set the value for the items displayed in the drop-down list.
  • IsDropDownOpen—Used to open or close the Drop-down list by setting its value as True or False.
  • SelectionChanged.
  • TextChanged.

Using basic core features in an application

In the SelectionChanged event the SelectedIndex, SelectedItem & SelectedValue properties can be used in the application to get these property values. The properties and events listed can be used in the application as mentioned below.

List<String> Products = new List<String>();

Products.Add("Business Intelligence");

AutoComplete autoComplete1 = new AutoComplete();
autoComplete1.CustomSource = Products;
autoComplete1.SelectedIndex = 1;
autoComplete1.IsDropDownOpen = true;
autoComplete1.SelectionChanged += 

new SelectionChangedEventHandler(autoComplete1_SelectionChanged);
autoComplete1.TextChanged += new PropertyChangedCallback(autoComplete1_TextChanged);
void autoComplete1_TextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    this.textBlock.Text = this.autoComplete1.Text;

void autoComplete1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    MessageBox.Show("SelectedItem: " +
    this.autoComplete1.SelectedItem.ToString()+ "\n" + "SelectedValue: "
    + this.autoComplete1.SelectedValue.ToString())

WPF Sample Browser-> Tools -> Editors -> AutoComplete Demo