StackOverflowVeryHelpful
StackOverflowVeryHelpful

Reputation: 2427

WPF ComboBox using letter keys for selecting items

I have a combo box in my application and when the drop down is open I would like the user to be able to type a letter and have the drop down skip to that selection. Currently it doesn't skip to the selection. I looked up couple of stackoverflow questions and applied the changes mentioned by them

IsTextSearchEnabled="True" TextSearch.TextPath="{Binding Name}"

WPF ComboBox using shortcut keys for selecting items

How to select item by typing a keyboard letter key in WPF combobox?

<ComboBox x:Name="serviceSelection" Grid.Row="0" Grid.Column="1"
                                          IsTextSearchEnabled="True"
                                         TextSearch.TextPath="{Binding Name}"
                                          VerticalAlignment="Top"
                                          Height="25"
                                          HorizontalAlignment="Right"
                                          Width="210"
                                          ItemsSource="{Binding ServiceRootNodes}"
                                          SelectionChanged="ServiceSelection_SelectionChanged"
                                          SelectedIndex="0">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>                                               
                                            <TextBlock Text="{Binding Name}" />
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>

Can someone provide me suggestions/feedback on what am i doing wrong ? Also in which cases does comboxBox letter search doesn't work?

Upvotes: 1

Views: 2623

Answers (2)

Subhas S
Subhas S

Reputation: 21

Try giving the property name instead of binding

TextSearch.TextPath="Name"

Upvotes: 2

Related Questions