Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 使用字符串键绑定到索引属性_Wpf_Vb.net_Xaml_Dictionary_Idictionary - Fatal编程技术网

Wpf 使用字符串键绑定到索引属性

Wpf 使用字符串键绑定到索引属性,wpf,vb.net,xaml,dictionary,idictionary,Wpf,Vb.net,Xaml,Dictionary,Idictionary,假设我想用XAML绑定到TKey是字符串的字典: <Label DataContext="{MyDictionary}" Content="{Binding Item("OK")}" /> 不起作用 我该怎么做 我说的是项目(“关键”)试试: <Label DataContext="{Binding MyDictionary}" Content="{Binding [OK]}" /> 或者(简单一点): 嗯,我知道列表索引是可能的,但我不确定字典键。。我刚试

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

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

不起作用

我该怎么做

我说的是项目(“关键”)

试试:

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

或者(简单一点):



嗯,我知道列表索引是可能的,但我不确定字典键。。我刚试过,结果成功了;)对我来说,第一个建议是这样的。但是,当键有空格或其他特殊字符(如句点和斜杠)时,这不起作用。我试着把钥匙放进双引号和单引号中,但都不起作用。
<Label Content="{Binding MyDictionary[OK]}" />