【发布时间】:2012-12-10 11:05:24
【问题描述】:
我有一本测试词典
MyDict = new Dictionary<string, Uri>
{
{"First", new Uri("alma.jpg", UriKind.Relative)},
{"Second", new Uri("korte.jpg", UriKind.Relative)}
};
还有一个简单的 XAML
<TextBlock Text="{Binding MyDict[First]}"
FontSize="13" Width="200" Height="30" />
这完美地展示了第一个关键元素的价值
我想要的是 我有一个字符串变量:DictKey 让 DictKey="First"
如何重写 XAML 以使用此变量
<TextBlock Text="{Binding MyDict[???DictKey????]}"
FontSize="13" Width="200" Height="30" />
谢谢。
【问题讨论】:
-
如何格式化代码块请看here。
标签: wpf binding dictionary