简体   繁体   English

WPF ComboBox 编辑文本自动完成

[英]WPF ComboBox editing text AutoCompletion

I have a ComboBox that contains a list of words.我有一个包含单词列表的 ComboBox。 Some of them are abbrivations consisting of capital letters.其中一些是由大写字母组成的缩写。 Let's assume you have the following words in the list:假设您在列表中有以下单词:

... other words
CA
... other words

When you type the c (lowercase) the ComboBox makes the c uppercase and displays a selected capital A afterwards.当您键入 c(小写)时,ComboBox 使 c 大写,然后显示选定的大写字母 A。 When you continue typing "ar" the text in the ComboBox results in "CAr" though you typed "car" (all lowercase).当您继续输入“ar”时,ComboBox 中的文本会导致“CAr”,尽管您输入的是“car”(全部小写)。 The word "car" is not a member of the list. “汽车”一词不在列表中。 Is there a way to get the WinForms ComboBox' behaviour or at lease make sure that the uppercase/lowercase is preserved for words that are not part of the attached word list.有没有办法获得 WinForms ComboBox 的行为,或者至少确保为不属于附加单词列表的单词保留大写/小写字母。

You can set 你可以设定

<ComboBox IsTextSearchCaseSensitive="True" />

to enable context-sensitive searching which preserves the case of the letters. 以启用上下文相关搜索,从而保留字母的大小写。

Hi Very late to the party.嗨,聚会很晚了。 ShouldPreserveUserEnteredPrefixProperty will prevent the combobox autocomplete changing the case of the text you've already entered :) ShouldPreserveUserEnteredPrefixProperty将阻止组合框自动完成更改您已经输入的文本的大小写:)

It only works when IsTextSearchCaseSensitive = false .它仅在IsTextSearchCaseSensitive = falseIsTextSearchCaseSensitive

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM