Associating an Indexed Property with a String Key

Say I want to bind to a dictionary that TKey is a XAML string:

<Label DataContext="{MyDictionary}" Content="{Binding Item("OK")}" /> 

Does not work.

How can I do it?

I'm talking about Item ("Key")

+4
source share
1 answer

Try the following:

 <Label DataContext="{Binding MyDictionary}" Content="{Binding [OK]}" /> 

Or what (a little easier):

 <Label Content="{Binding MyDictionary[OK]}" /> 
+12
source

All Articles