Proposal: Allow `ComboBox` `IsTextSearchEnabled` when `ItemTemplate` provided
See original GitHub issueProposal: Allow ComboBox
IsTextSearchEnabled
when ItemTemplate
provided
Summary
IsTextSearchEnabled
allows users to type characters into a ComboBox
and jump to the entry starting with that letter. However, this only works if the ItemsSource
is a list of strings (understandably so). It would be nice to provide some kind of API to enable this feature when the ItemsSource
is a custom object and the ComboBoxItem
s are presented as more complex views of the bound item.
Rationale
- Customizing the appearance of
ComboBox
items is not uncommon. In the example above, all I’ve added is an icon. - TextSearch is a very useful feature. Users can get confused if some ComboBoxes have it enabled (because they are bound to strings) and others don’t.
- The developer could try to implement this manually, but then they are at risk of implementing it slightly differently. A first party solution would be preferred.
Scope
Capability | Priority |
---|---|
This proposal will allow developers to accomplish W | Must |
This proposal will allow end users to accomplish X | Should |
This proposal will allow developers to accomplish Y | Could |
This proposal will allow end users to accomplish Z | Won’t |
Important Notes
Example:
Windows Terminal binds ComboBox.ItemsSource
to the settings model as such:
<ComboBox x:Name="DefaultProfile"
ItemsSource="{x:Bind State.Settings.AllProfiles, Mode=OneWay}"
SelectedItem="{x:Bind CurrentDefaultProfile, Mode=TwoWay}"
Style="{StaticResource ComboBoxSettingStyle}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="SettingsModel:Profile">
<Grid HorizontalAlignment="Stretch" ColumnSpacing="8">
<Grid.ColumnDefinitions>
<!-- icon -->
<ColumnDefinition Width="16"/>
<!-- profile name -->
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<IconSourceElement
Grid.Column="0"
Width="16"
Height="16"
IconSource="{x:Bind Icon,
Mode=OneWay,
Converter={StaticResource IconSourceConverter}}"/>
<TextBlock Grid.Column="1"
Text="{x:Bind Name}"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
where State.Settings.AllProfiles
is an observable vector of profile objects. All we’re doing in this template is adding an icon. Binding to Profile
objects allows us to bind SelectedItem
and have this work fairly straightforward with little modifications.
Open Questions
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to do text search in DropDown of ComboBox with ...
Set the IsTextSearchEnabled property to true and the TextSearch.TextPath attached property to either "LastName" or"FirstName" or whatever ...
Read more >ComboBox.IsTextSearchEnabled Property - UWP
Gets or sets a value that specifies whether a user can jump to a value by typing.
Read more >Multiple Selection - WPF ComboBox - Documentation - Telerik
To enable the multiple selection, set the AllowMultipleSelection property to True as shown in Example 1. Example 1: Allowing multiple selection. XAML.
Read more >XamComboEditor with drop down grid
Hi. In the winforms version of your combobox there is a nice feature to be able to bind a dataset to the combobox...
Read more >The ComboBox control
A complete walkthrough of how and when to use the WPF ComboBox control. ... Let's try making a slightly more sophisticated list of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha! Turns out you need the
Windows.Foundation.IStringable
interface. Then it works!I guess the only ask I have here is to please include this in the docs. Thanks for the quick response folks! Closing!
Yup. Dustin and I were chatting on teams haha