Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding to indexed property with String key

Say I wanna bind to dictionary that TKey is string with XAML:

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

Doesn't work.

How should I do it?

I am talking about the Item("Key")

like image 705
Shimmy Weitzhandler Avatar asked Dec 18 '22 06:12

Shimmy Weitzhandler


1 Answers

Try that :

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

Or that (a bit simpler) :

<Label Content="{Binding MyDictionary[OK]}" />
like image 73
Thomas Levesque Avatar answered Dec 21 '22 23:12

Thomas Levesque