说我想绑定到TKey与XAML字符串的字典:

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

不起作用。

我该怎么做?

我说的是项目(“Key”)

有帮助吗?

解决方案

试试:

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

或者那(更简单):

<Label Content="{Binding MyDictionary[OK]}" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top