WPF - AutoSuggest Editor (v19.1)

WPF Team Blog
23 April 2019

The AutoSuggestEdit is an editor that displays a drop-down list with suggestions as the user types in the text box. At a glance, it looks similar to the ComboBoxEdit, but it has unique features to support the following use cases:

Dynamic Suggestions For Advanced Search Scenarios

The AutoSuggestEdit can display a dynamically populated list of suggestions and highlight the search text in each result item. The editor allows you to include only matching items, so it can be used to search huge data sources without any UI performance degradation.

Highlight Search Text

You fully control which items to display in the suggestion list, so it is easy to implement use cases where data is retrieved from custom search engines, fuzzy search implementations, remote web services or other sources.

Flexible Popup Control

You can use any control as the editor popup, e.g. a Data Grid or a Tree List.

Flexible Popup Control

Event Controlled

The AutoSuggestEdit is controlled by events:

  • The event QuerySubmitted fires when the end user changes the editor text. In the event handler, you need to retrieve the search text and use it to perform the search. Implementing the search logic is up to you, which provides the flexibility to utilize any search mechanism. You generate a result collection and assign it to the ItemsSource property of the editor.
void AutoSuggestEdit_OnQuerySubmitted(object sender,
  AutoSuggestEditQuerySubmittedEventArgs e) {
  ((AutoSuggestEdit) sender).ItemsSource =
    string.IsNullOrEmpty(e.Text)
      ? null
      : this.context.CountriesArray
        .Where(x => Regex.IsMatch(x, Regex.Escape(e.Text),
          RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace))
        .Take(10)
        .ToArray();
}
  • SuggestionChosen is the event that fires when the end user selects a suggestion from the editor popup. Handle this event to update the editor text when a new item is selected.

Please Tell Us What You Think

You can see the AutoSuggestEdit in action by following this link (you need an installation of DXperience v19.1 Beta with demos on your machine): AutoSuggestEdit Demo

As always, we welcome your feedback. Please feel free to leave a comment and let us know what you think of the new editor.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.