tags:

views:

981

answers:

1

I cant seem to find a direct method for implementing filtering of text input into a list of items in a WPF combobox.
By setting IsTextSearchEnabled to true, the comboBox dropdown will jump to whatever the first matching item is. What I need is for the list to be filtered to whatever matches the text string (e.g. If I focus on my combobox and type 'abc', I'd like to see all the items in the ItemsSource collection that start with (or contain preferably) 'abc' as the members of the dropdown list).

I doubt that it makes a difference but my display item is templated to a property of a complex type :

<ComboBox x:Name="DiagnosisComboBox" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" 
          ItemsSource="{Binding Path = ApacheDxList,
                                UpdateSourceTrigger=PropertyChanged,
                                Mode=OneWay}"
          IsTextSearchEnabled="True"
          ItemTemplate="{StaticResource DxDescriptionTemplate}" 
          SelectedValue="{Binding Path = SelectedEncounterDetails.Diagnosis,
                                  Mode=TwoWay,
                                  UpdateSourceTrigger=PropertyChanged}"/>

Thanks.

+1  A: 

It sounds like what you are really looking for is something similar to an auto-complete textbox, which provides completion suggestions in a popup similar to a combobox popup.

You might find this CodeProject article useful:

A Reusable WPF Autocomplete TextBox

Aviad P.
This looks pretty cool, maybe I'm not implementing it correctly yet. I need the entire list to be available if they dont want to use the search feature. How would one select from the entire list?Also, while I can bind the ItemsSource to your control (using the binding in my example above), I cant actually select something in the list...the text area is always empty. Finally, this control is central to a group of controls. I need SelectedItem in adjacent controls, as in : SelectedValue="{Binding SelectedItem.SomeOtherProperty, ElementName=DiagnosisComboBox...}"/>
Bob
Check out the article again, it provides for everything you require. If you want to make the entire list available, clear the `MaxCompletions` property, and have your filter predicate always return true. To enable actually selecting something from the list you need to set the `Binding` property to one of the properties of your data objects in the list.
Aviad P.