将组合框中所选项目的组合框 属性 绑定到字段

Bind combobox property of selected item in combobox to field

我在 ComboBox 中绑定时遇到问题。我在 Google 等地方搜索过,但我没能找到答案。

我有这样的带有组合框的 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> 场地。这对我来说似乎并不明显。所以我需要将所选项目的值绑定到我的字段,但不知道该怎么做。

谢谢。

解决方案一如既往的简单:

SelectedValuePath="Value"
SelectedValue="{Binding Path=Firm, Mode=TwoWay}">