private static void Text_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { AutoCompleteBox autoCompleteBox = (AutoCompleteBox)d; // Remember the "SearchText": if (autoCompleteBox._textBox != null) { autoCompleteBox._searchText = autoCompleteBox._textBox.Text ?? ""; } else { autoCompleteBox._searchText = ""; } // Raise the "OnTextChanged" user event: autoCompleteBox.OnTextChanged(new RoutedEventArgs()); // Open or close the popup: if (autoCompleteBox.MinimumPrefixLength <= autoCompleteBox.Text.Length) { //---------------------------------- // ENOUGH LENGTH //---------------------------------- if (autoCompleteBox.MinimumPopulateDelay != 0) { //---------------------------------- // TICK EVENT BECAUSE THERE IS A DELAY SET //---------------------------------- autoCompleteBox._timer.Stop(); autoCompleteBox._timer.Start(); } else { //---------------------------------- // NO TICK EVENT BECAUSE DELAY IS 0 //---------------------------------- autoCompleteBox._timer.Stop(); // We update the panel, with the new text by opening the popup: autoCompleteBox.IsDropDownOpen = true; } } else { //---------------------------------- // NOT ENOUGH LENGTH //---------------------------------- autoCompleteBox.IsDropDownOpen = false; } }
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { AutoCompleteBox autoCompleteBox = (AutoCompleteBox)d; autoCompleteBox.OnTextChanged(new RoutedEventArgs()); }