【发布时间】:2020-01-31 17:14:02
【问题描述】:
以上是我想要获得的期望行为。 Instrument 中的值应用作访问存储价格的字典的键。 假设我们有一些货币集合,它们在项目控件中显示,如下所示:
<ItemsControl Background="White" Name="currenciesList" ItemsSource="{Binding Currencies}">
我们定义了一个数据模板来描述如何使用以下属性来呈现列表中的每种货币:
<ComboBox Name="cmbbx" Height="20" Width="60" Grid.Column="1" ItemsSource="{Binding Path=InstrumentTypes}" SelectedItem="{Binding CurrencyInstrument}" IsSynchronizedWithCurrentItem="False">
</ComboBox>
<TextBlock Name="purchase_price" Grid.Column="2" Text="{Binding What do I put here??}">
</TextBlock>
<TextBlock Name="sale_price" Grid.Column="3" Text="{Binding What do I put here??}"/>
对于文本块绑定,我想要一个像 PurchaseInstruments[CurrencyInstrument] 这样的表达式,其中 PurchaseInstruments 是 Dictionary 属性,CurrencyInstrument 是另一个存储要在字典中使用的键值的属性。我怎样才能实现这种行为?
请忽略图片中的不良格式。
【问题讨论】:
标签: c# wpf dictionary data-binding