C# 滚动至下拉列表中与按下的键匹配的列表
我正在开发一个UWP应用程序,我有一个下拉列表,上面有国家名称、国旗和国家代码。当我单击下拉列表时,打开国家列表。但是,如果我点击并按下任何字母e.g I,它不会自动滚动到列表以I开头的位置 我已尝试将IsTextSearchEnabled属性添加到下拉列表中,但没有得到所需的结果。有人能告诉我这里需要做什么吗C# 滚动至下拉列表中与按下的键匹配的列表,c#,xaml,uwp,combobox,C#,Xaml,Uwp,Combobox,我正在开发一个UWP应用程序,我有一个下拉列表,上面有国家名称、国旗和国家代码。当我单击下拉列表时,打开国家列表。但是,如果我点击并按下任何字母e.g I,它不会自动滚动到列表以I开头的位置 我已尝试将IsTextSearchEnabled属性添加到下拉列表中,但没有得到所需的结果。有人能告诉我这里需要做什么吗 <ComboBox x:Name="CmbCountrylist" Height="auto" IsEditable="True" IsTextSearchEnabled="T
<ComboBox x:Name="CmbCountrylist" Height="auto" IsEditable="True"
IsTextSearchEnabled="True" Width="250" Margin="0,0,1,0" Background="red"
PlaceholderText="Select Country"
SelectionChanged="CmbCountryCodes1_SelectionChanged"
HorizontalAlignment="Left" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" ToolTipService.ToolTip="{Binding name}" >
<Image x:Name="ImgFlag" Width="16" Height="16" Margin="0,2,5,2" VerticalAlignment="Center" HorizontalAlignment="Left" Source="{Binding ImagePath}" />
<TextBlock x:Name="txtCountryName" Text="{Binding name}" />
<TextBlock x:Name="txtCode" Text="{Binding dial_code}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
根据您的描述,绑定的数据源是一个类。在这种情况下,请重写类的ToString方法以返回国家名称 公营国家 { //其他属性 公共重写字符串ToString { 返回名称; } } 在组合框中输入文本时,组合框将匹配数据列表中的数据,但组合框不会主动查找类的属性,而是查找ToString方法的值
致以最诚挚的问候。如果您的问题已得到解决,请稍后访问此帖子的方便人士将其视为已接受