绑定到datagrid中的comboBox的selectedValue - wpf

时间:2013-01-09 18:23:39

标签: wpf combobox datatemplate

我是WPF的新手。我已成功在后面的代码中填充了ComboBox内的DataTemplate,其中包含以下内容:

                  <DataGridTemplateColumn Header="Action">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox Name="ddErrAction" Loaded="ddErrAction_Loaded" SelectedValue="{Binding ElementName=grdErr, Path=errActionCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

并在代码背后:

    Private Sub ddErrAction_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)
    If TypeOf e.Source Is ComboBox Then
        Dim myDD As ComboBox = CType(e.Source, ComboBox)
        myDD.ItemsSource = listErrActions
        myDD.DisplayMemberPath = "errActionDesc"
        myDD.SelectedValuePath = "errCode"
    End If
End Sub

我的问题是虽然我看到了itemsItem或SelectedValue永远不会绑定的项目列表。我无法弄清楚我做错了什么。有什么建议吗?

0 个答案:

没有答案