WPF组合框...如何设置。文本属性? [英] WPF ComboBox...how to set the .Text property?
问题描述
有没有一种方法来设置WPF ComboBox控件直接?
Is there a way to set the .Text
property of the Wpf ComboBox control directly?
我的组合框的。文本
属性绑定到列表< T>
收藏,但是当我尝试设置。文本
在<$ c属性$ C> DropDownClosed 事件,它完全忽略它。
My combobox is bound to a List<T>
collection, but when I try to set .Text
property in the DropDownClosed
event, it totally ignores it.
推荐答案
如果你想设置的文本中它应该正常工作列表中的项目中的一个的文本。
If you're trying to set the text to the text of one of the items in the list it should work correctly.
如果你想将它设置为不在列表中的那么IsEditable属性需要是真实的项目。您可以设置IsReadOnly属性为true,如果你不真正希望用户输入到组合框。
If you're trying to set it to an item that isn't in the list then the IsEditable property needs to be true. You can set the IsReadOnly property to true if you don't actually want users typing into the combo box.
如果这些情况都不适合你,你能张贴代码您正在使用?
If none of these cases fit you, can you post the code you're using?
这篇关于WPF组合框...如何设置。文本属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!