【发布时间】:2014-07-02 00:28:45
【问题描述】:
我的应用程序中有一个组合框,当下拉菜单打开时,我希望用户能够键入字母并让下拉菜单跳到该选项。目前它不会跳到选择。我查找了几个 stackoverflow 问题并应用了他们提到的更改
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>
有人可以就我做错了什么向我提供建议/反馈吗?还有在哪些情况下,comboxBox 字母搜索不起作用?
【问题讨论】:
-
发现我的错误:应该只是 TextSearch.TextPath="Name"
标签: c# wpf xaml combobox wpf-controls