将数据表绑定到datagridTemplateColmun中的ComboBox [英] Bind Datatable To ComboBox in datagridTemplateColmun
本文介绍了将数据表绑定到datagridTemplateColmun中的ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi每个
一个我有WPF DataGrid并且它的列称为Code,它是一个datagridtemplateColumn,我将ComboBox放在此列中,但是我尝试填充comboBox IemsSource,但是我无法从代码到达Combo Box(This.Cmx_Code.ItemsSource是不允许的),如何填充组合框的项目来源
hi Every
one i has WPF DataGrid and it has Column Called Code it is a datagridtemplateColumn , i put ComboBox in this Column but i try to fill the comboBox IemsSource and i could not reach to the Combo Box From Code (This.Cmx_Code.ItemsSource is Not Allowed ) so how can i fill the itemsSource of the Combo Box
<datagridtemplatecolumn loc:translate.uid="1658" header="Code" width="*" xmlns:x="#unknown" xmlns:loc="#unknown">
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<combobox x:name="Cmx_Code" selectionchanged="Cmx_Kind_SelectionChanged" itemssource="{Binding}">
<combobox.displaymemberpath>Code</combobox.displaymemberpath>
<combobox.selectedvaluepath>Med_ID</combobox.selectedvaluepath>
<combobox.selectedvalue>
<binding>
<binding.path>Med_ID</binding.path>
<binding.mode>TwoWay</binding.mode>
<binding.updatesourcetrigger>PropertyChanged</binding.updatesourcetrigger>
</binding>
</combobox.selectedvalue>
</combobox>
</datatemplate>
</datagridtemplatecolumn.celltemplate>
</datagridtemplatecolumn>
推荐答案
尝试使用DataBinder.Eval()函数 ^ ]
try using DataBinder.Eval() function http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx[^]
这篇关于将数据表绑定到datagridTemplateColmun中的ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文