I have a simple Dictionary defined as ResultOptions = new Dictionary<char, string>
and my viewmodel has a public property ResultCode of type char. My XAML is as follow:
<ComboBox ItemsSource="{Binding ResultOptions}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
SelectedValue="{Binding ResultCode}" />
Everything is working great except the ComboBox is never initialized based on the value of SelectedValue. I'm sure the binding is correct since i'm able to see that the ResultCode in the viewmodel is set properly.
The strange thing is...if i change my model to have ResultCode to be of type 'string' and my dictionary is Dictionary<string,string>
, then the combobox is initialized properly based on the SelectedValue.
What's am i missing? why is binding to Dictionary<string, string>
works, but binding to Dictionary<char, string>
doesn't?