I have a dictionary collection and i need to bind it to Silverlight ListBox. I am unable to bind to ListBox using the Key value.
Below is the Sample Code.. I get empty record
Dictionary in the code behind..
Dictionary<DayOfWeek, List<Book>> bookItem = new Dictionary<DayOfWeek, List<Book>>();
<ListBox x:Name="ListValues" ItemsSource="{Binding bookItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding BookName[Tuesday]}"></TextBlock>
<TextBlock Text="{Binding BookDesc[Tuesday]}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
IDictionary.GetEnumerator returns a collection of
KeyValuePair<TKey, TValue>. So, in order to bind to your objects you need to use the properties on KeyValuePair.Here is an example of how you can display the data.