I have a ComboBox
, and I have bound a Dictionary
to it. Here is the code:
<ComboBox Height="24" Name="comboBoxQuery" Width="300" ItemsSource="{Binding QueryNames}" SelectedItem="{Binding SelectedQueryNames}" SelectedValuePath="Key" DisplayMemberPath="Value" Visibility="{Binding Path=ComboVisibility, Converter={StaticResource BoolToVis}}" />
Now, when I try to fetch the selected value, I get a string with key and value together. Ex: [1, "ABC"]
my view model code:
public Dictionary<int, string> QueryNames
{
get
{
return m_ReadOnlyQueryNames;
}
set
{
m_queryNames = value;
OnPropertyChanged("QueryNames");
}
}
private string m_SelectedQueryNames;
public string SelectedQueryNames
{
get
{
return m_SelectedQueryNames;
}
set
{
if (m_SelectedQueryModule != value) <!-- value returns [1, "abc"]-->
{
m_SelectedQueryModule = value;
OnPropertyChanged("SelectedQueryNames");
}
}
}