Search code examples
c#wpfsearchautocompletebox

camel case search in WPF AutoCompleteBox


How implement camel case search (search words with capital letters) in WPF AutoCompleteBox. Example: consider my items source contains "Phone Number" then if we type "pn" in text box it suggest phone number in drop down.


Solution

  • You can set the FilterMode to custom and set a ItemFilter predicate to something similar to:

    autoBox.FilterMode = AutoCompleteFilterMode.Custom;
    autoBox.ItemFilter = new AutoCompleteFilterPredicate<object>((searchText, obj) => 
                        (obj as string).Where(x=>Char.IsUpper(x))
                                       .SequenceEqual(searchText.ToUpper()));