【发布时间】:2016-07-25 19:16:17
【问题描述】:
我在 ComboBox 中遇到了绑定问题。我已经在谷歌等中搜索过,但我一直无法找到答案。
我有像这样的组合框的silverlight表单:
<ComboBox x:Name="FirmBox"
Grid.Row="23"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5,5,5,0"
SelectedValuePath="{Binding Path=Value, Mode=TwoWay}"
SelectedItem="{Binding Path=Firm, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Value}"/>
<TextBlock Text="{Binding Path=Key}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
ItemsSource 是一个
ObservableCollection<KeyValue<String, KeyValue<String, String>>>
所以我想出了如何以正确的方式显示它,但我不知道如何将所选项目绑定到我的KeyValuePair<String, String>
场地。这对我来说似乎并不明显。所以我需要将所选项目的值绑定到我的字段,不知道该怎么做。
谢谢。
【问题讨论】:
标签: c# silverlight