Reputation: 568
I have the editable ComboBox that using binding to dictionary:
<ComboBox IsEditable="True" ItemsSource="{Binding MyDict}" DisplayMemberPath="Value" SelectedValuePath="Value" SelectedValue="{Binding MyProp}" />
Sometimes I need set in code to property MyProp some different value, that is not presented in the dictionary. In such situation ComboBox is not dispalay the value.
What should I do to ComboBox be able to display arbitrary value in this case?
Upvotes: 1
Views: 60
Reputation: 169270
A ComboBox
cannot select arbitrary values. It can only select a value or item that is present in its Items
or ItemsSource
collection.
So you must add an entry to MyDict
before you can select it. You may set the Text
property of the ComboBox
to a random string
, but this won't select any item and set the MyProp
property.
Upvotes: 1