使用String键绑定到索引属性
-
07-07-2019 - |
题
说我想绑定到TKey与XAML字符串的字典:
<Label DataContext="{MyDictionary}" Content="{Binding Item("OK")}" />
不起作用。
我该怎么做?
我说的是项目(“Key”)
解决方案
试试:
<Label DataContext="{Binding MyDictionary}" Content="{Binding [OK]}" />
或者那(更简单):
<Label Content="{Binding MyDictionary[OK]}" />
不隶属于 StackOverflow