I have a ComboBox like this:
<ComboBox IsEditable="True"
ItemsSource="{Binding SelectableValues}"
SelectedValue="{Binding SelectedValue}" />
SelectableValues is a list of double and SelectedValue is a double. If the user chooses a value from the list or manually enters one of those values, my SelectedValue property is updated. But if the user manually enters another value, it isn’t. How do I allow SelectedValue to take other values than those in ItemsSource?
Edit: Think of it like the font size box in MS Word. I can choose a value from the list, or provide my own value.
Create a user control inheriting comboBox. Add a dependency property as ‘SelectedText’. create event handler for LostFocus on combo box, in event handler assign the entered value dependency property ‘SelectedText’.
do binding on ‘SelectedText’, in its setter if value is new then ad to collection and set SelectedValue to new one.
Indirectly you have to update source by adding new property in ComboBox.