在数据网格中绑定组合框 [英] Binding a combobox in a datagrid

查看:76
本文介绍了在数据网格中绑定组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用SelectedValueBinding绑定DataGridComboBox,它可以正常工作。我对DataGridComboBoxColumn的XAML编码属性



I can bind a DataGridComboBox using the SelectedValueBinding and it works ok. My XAML coded properties for DataGridComboBoxColumn

Header="Empl ID"
ItemsSource="{Binding Source={StaticResource csv}}"
DisplayMemberPath="EmployeeID"
SelectedValuePath="EmployeeID"
SelectedValueBinding="{Binding EmployeeID, UpdateSourceTrigger=PropertyChanged}">







但是当我尝试在DataGridTemplateColumn中绑定Combobox时,SelectedValueBinding 不可用。以下是我上次更新的代码。当窗口打开时,组合框打开到第一个记录,但应该是与网格中的行对应的记录。






But when I try to bind the Combobox within a DataGridTemplateColumn, the "SelectedValueBinding" is not available. Following is my last updated code. When the window is opened the combobox opens to the first record, but should be the record corresponding to the row in the grid.

DataGridTemplateColumn Header="Empl ID">
    DataGridTemplateColumn.CellTemplate>
          DataTemplate>
              ComboBox ItemsSource="{Binding Source={StaticResource csv}}" 
                         DisplayMemberPath="EmployeeID"
                         SelectedValuePath="EmployeeID"
                         SelectedValue="{Binding Path=EmployeeID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         TextSearch.TextPath="EmployeeID">







任何建议?



谢谢



我尝试过:



我尝试了很多东西,最后一个是添加TextSearch属性。




Any Suggestions?

Thanks

What I have tried:

I've tried numerous things, with the last being adding the TextSearch property.

推荐答案

HI ,

请参阅以下链接,它会对您有所帮助。



在DataGridView单元中绑定并显示一个ComboBox - Windows应用程序 - C#和Vb.Net [ ^ ]


这篇关于在数据网格中绑定组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆