Wpf combobox text property binding problem

bindingcomboboxwpf

I am trying to bind to a combobox text with the IsEditable property set to true. I have a property in my viewmodel which is bound to the text.

I want to validate on the text being typed in the text of the combobox, and restrict some values that the user is typing in. So some will be allowed, and some not, and these need to set the combobox back to its old value.

I do this in the view model and I have tried setting my text property in my view model explicity to the old value or just ignoring the change and raising that the property has been changed, but for the life of me it will not refresh the text back to the old value.

Is this because the combobox is editable, and it has the text caret and focus somewhere in the text of the combobox.

Basically, I want it to refresh back to the previous text when I restrict some typing in the combobox during in editing. Anyone have any ideas to reset the text back to its old value through the ViewModel. Thanks in advance!

Best Answer

Thanks for your replies. But I could never get it to work instead, I made my own UserControl which comprises a textbox overlayed over a combobox, and manipulate those two controls to meet my needs. A long way to go to solve a simple problem, but it works in the end.