使用Visual Studio 2010和WPF向ComboBox添加值 [英] Adding values to ComboBox using Visual Studio 2010 and WPF

查看:114
本文介绍了使用Visual Studio 2010和WPF向ComboBox添加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2010环境中使用WPF和C#。

I'm using WPF and C# in the Visual Studio 2010 environment.

我创建了一个包含预先存在的值列表的ComboBox。 由于新的要求,我现在需要使用户能够在运行时向ComboBox添加新值。

I have created a ComboBox with a pre-existing list of values.  Due to new requirements, I am now needing to make it possible for the user to add new values to the ComboBox during runtime.

我已经将IsEditable设置为"True"并且IsReadOnly为"False"。

I have already set IsEditable to "True" and IsReadOnly to "False".

如果我输入的值不在列表中:

If I enter a value that is not in the list:

如果新值以相同的值开头字母作为预先存在的值,应用程序将使用第一次按键导航到预先存在的值,而不是接受键击作为新值中的第一个字符。 但是,
如果键入ComboBox的新值不是以与任何预先存在的值相同的字母开头,则应用程序会成功将新值添加到有效选项列表中。

If the new value begins with the same letter as a pre-existing value, the application will use that first keystroke to navigate to the pre-existing value, rather than accepting that keystroke as the first character in a new value.  However, if the new value typed into the ComboBox does not begin with the same letter as any pre-existing value, the application successfully adds the new value to the list of valid choices.

关于如何解决这个问题的任何建议?

Any suggestions as to how to solve this problem?

推荐答案

这可以解决这个问题。

This would solve this problem.

<ComboBox IsTextSearchEnabled="false"/> 





这篇关于使用Visual Studio 2010和WPF向ComboBox添加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆