Select the Value of a Dictionary in a ComboBox Wpf

1

I have the following code.

ajusteCbb.ItemsSource = new Dictionary<string, string> { { "A", "SI" }, { "C", "NO" } };
ajusteCbb.DisplayMemberPath = "Value";
ajusteCbb.SelectedValuePath = "Key";

and in a Datagrid I have this code

<DataGridComboBoxColumn x:Name="ajusteCbb" Header="Ajuste" SelectedItemBinding="{Binding Path=Ajuste}"></DataGridComboBoxColumn>

Then with that I already show the values in the combobox and I select it.

The problem is that when I look at what I select, I take the following

[C, NO]

But if I told you that the selectedvaluepath was key because I'm not taking C as a value ??? What am I wrong?

    
asked by Cristian 01.07.2016 в 00:09
source

1 answer

0

The solution was to change SelectedItemBinding by

SelectedValueBinding="{Binding Path=IdUnidadMedida}"
    
answered by 01.07.2016 / 16:03
source