4

假设我想绑定到 TKey 是 XAML 字符串的字典:

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

不工作。

我该怎么做?

我说的是 Item("Key")

4

1 回答 1

12

试试看:

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

或者那个(更简单一点):

<Label Content="{Binding MyDictionary[OK]}" />
于 2009-09-14T09:40:09.293 回答