To talk in detail about the good answers that have already been given.
Firstly, jesse answer - set IsTextCompletionEnabled="True"
, simple - fills the text field after each key press with the first element in the list. When you press the enter button, the popup closes. The reason I did not use this approach is because it immediately updates the SelectedItem
, without waiting for the user to press the enter key.
Sico's answer is what I used. GetTemplateChild
method requires subclassing the AutoCompleteBox
control. Here is the code:
public class ExtendedAutoCompleteBox : AutoCompleteBox { protected override void OnKeyDown(KeyEventArgs e) { if (e.Key == Key.Enter) { UpdateSelection(); } } private void UpdateSelection() {
source share