0
votes

I have a combobox and a separate texbox. I have set the datacontext of the combobox as a view model that specifies the history of entered text in the textbox. What I need is to have the selected value in combobox update to the text in the textbox instantaneously, after clicking in the specified item in the combobox. I have achieved this by binding the textbox text to the combobox selecteditem and setting the mode to twoway. But the issue I have run into is that when I write something in the textbox, and then click in the combobox, the first combobox item is replaced with the textbox text, when instead I want the (append) update in the combobox items to happen only after the user enters text in textbox and hits the return key. Any pointers?

1

1 Answers

0
votes

First of all you need to remove the binding of the ComboBox and TextBox. Then,

In Button Command Delegate add SearchText to the ObservableCollection<string> HistoryItems

HistoryItems.Add(SearchText);