I am trying to select a ComboBox item to set a stored value from a database.
It saved “I” or “D” in the database, and the converter returns “Direct” or “Indirect”.
ComboBox has two ComboBoxItems with the values "Direct" and "Indirect".
Here is the code that I thought would work:
<ComboBox Name="cbMode"
SelectedValue="{Binding Context.mode, Converter={StaticResource ModeConverter}, Mode=TwoWay}" >
<ComboBoxItem Content="Direct" />
<ComboBoxItem Content="Indirect" />
</ComboBox>
I know that it returns "Indirect", but it is not selected.
When I try to change the selected item in combo, it does not work, because it cannot convert from ComboBoxItem to string, so I support this problem in both directions.
How do i try? Should I make SelectedIndex with a numeric converter?
Thanks in advance.
source