I have a combobox which is bound do a dictionary
Dictionary<String, myClass> boxItems;
The combobox has the following dataTemplate:
<DataTemplate>
<TextBlock Text="{Binding Path=Key}"></TextBlock>
</DataTemplate>
This works fine for loading the values and getting the selected value, however I can’t figure out how to set the selected value from codebehind.
any pointers?
I’ve tried setting selectedItem and selectedValue to a Key (which I know is in the dictionary), but when I load the page, the combobox hasn’t selected anything.
You need to create a KeyValuePair with the key you want to select.
You can do something like this: