WPF按键绑定到字典中的项目?

Son*_*oul 33 data-binding wpf xaml dictionary

我可以使用索引绑定到集合项:

<TextBlock FontStyle="Italic"  Text="{Binding Path=Exchanges[0].Name}" />
Run Code Online (Sandbox Code Playgroud)

但是使用字典键怎么样?

Path=Exchanges['AMEX'].Name
Run Code Online (Sandbox Code Playgroud)

Son*_*oul 58

是的......就像一个魅力

<TextBlock FontStyle="Italic"  Text="{Binding Path=ExchangesDictionary[AMEX].Name}" />
Run Code Online (Sandbox Code Playgroud)