如何绑定ComboBox

时间:2010-03-27 10:11:17

标签: wpf binding combobox wpfdatagrid

我有一个ComboBox,需要将其绑定到DataGrid。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

例如:

<tk:DataGrid x:Name="dgProducts" DataContext="GoodsCollection" IsSynchronizedWithCurrentItem="True" >
         <tk:DataGrid.Columns>
               <tk:DataGridComboBoxColumn Header="Good Name" 
                    x:Name="dgCbProduct" 
                            TextBinding="{Binding Path=GoodID, Converter={StaticResource GoodIDToGoodNameConverter}}"
                            SelectedValuePath="GoodName" 
                            DisplayMemberPath="GoodName">
                            </tk:DataGridComboBoxColumn>
          </tk:DataGrid.Columns>
</tk:DataGrid>