防止 WPF ComboBox 中的文本自动完成?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12281453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:13:27  来源:igfitidea点击:

Prevent text autocomplete in WPF ComboBox?

.netwpfvb.netcombobox

提问by Frosty840

I'm using this filtered WPF ComboBox controlfrom Diederik Krols.

我正在使用来自 Diederik Krols 的这个过滤的 WPF ComboBox 控件

I have found that it works fine for almost all cases but that entering in the first letter of any given item in the collection causes the ComboBox to automatically set its text property to the string representing that item, and therefore kill all further filtering. I can't even backspace away from the result when this happens, as pressing the backspace key causes the cycle to happen again.

我发现它几乎适用于所有情况,但输入集合中任何给定项目的第一个字母会导致 ComboBox 自动将其文本属性设置为表示该项目的字符串,因此终止所有进一步的过滤。发生这种情况时,我什至无法从结果中退格,因为按退格键会导致循环再次发生。

After much head-scratching, staring at the wall, and drooling like an idiot, I've finallyworked out that this is actually expected behaviour if the ComboBox has been set to AutoCompleteMode.Append. I need to set it to AutoCompleteMode.None.

经过多次挠头、盯着墙壁、像个白痴一样流口水之后,我终于发现,如果 ComboBox 已设置为 AutoCompleteMode.Append,这实际上是预期的行为。我需要将其设置为 AutoCompleteMode.None。

WPF ComboBoxesdon't appear to have an AutoCompleteMode property.

WPF 组合框似乎没有 AutoCompleteMode 属性。

Is there any way around this, to achieve AutoCompleteMode.None behaviour?

有没有办法解决这个问题,以实现 AutoCompleteMode.None 行为?

回答by GazTheDestroyer

<ComboBox IsTextSearchEnabled="false"/>