Reputation: 61606
Is there a way to set the .Text
property of the Wpf ComboBox control directly?
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.
Upvotes: 10
Views: 21973
Reputation: 179
You can also try adding one more ComboBoxItem with Visibility=Collapsed, set that one as the selected item and set its content to whatever is needed.
Upvotes: 0
Reputation: 46585
If you're trying to set the text to the text of one of the items in the list it should work correctly.
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?
Upvotes: 29