Reputation: 3168
I have a list:
public SortedDictionary<string, string> ProjectDictionaryList { get; internal set; }
Now I want to bind the value to ComboBox:
ComboBox DockPanel.Dock="Right" ItemsSource="{Binding Path=ProjectDictionaryList}"
IsSynchronizedWithCurrentItem="True" Style="{StaticResource myCombo}"
SelectedItem="{Binding SelectedProject}"
But how to bind ProjectDictionaryList.Value
?
Upvotes: 0
Views: 138
Reputation: 937
You can use DisplayMemberPath=""
to display the Values in combobox or
if you don't want to do that ProjectDictionaryList.Values
can be binded with the help of {Binding Path=}
Upvotes: 0
Reputation: 128070
Set DisplayMemberPath
and SelectedValuePath
and bind SelectedValue
to select a dictionary entry by its key:
<ComboBox
ItemsSource="{Binding ProjectDictionaryList}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
SelectedValue="{Binding SelectedProject}"/>
Upvotes: 3