I have a Dictionary in my C# code behind of a WPF application. I wanted to bind a Listbox to the Keys of that Dictionary, and that works.
But I'd also obviously like it to update whenever the Dictionary has new elements, or when some are deleted (I thought it was the basic usage of Binding oO)... and I got troubles with this because as far as I understood browsing the net, I should use a ObersvableCollection, which does not exist for dictionaries =/
Plus I'd very much prefer to use the dictionary as it is.
It looks like this:
<ListBox Margin="5"
Name="listBoxAvailableReplays"
Background="Transparent"
ItemsSource="{Binding}"
DataContext="{Binding UpdateSourceTrigger=PropertyChanged}"
/>
And the code-behind (that code is in the constructor):
listBoxAvailableReplays.DataContext =
m_IFileHandlingBaboon.AvailableReplays.Keys;