c# - Binding to DataGridComboBox -
i know has been asked few times, cannot binding work on datagridcombobox, never displays @ all. can show me error of ways?
c#
ilist<servicecodes> servicecodes = app.getinfo.getservicecodes(); newinvoice.invitemsdatagrid.datacontext = servicecodes; newinvoice.showdialog(); xaml
<datagrid x:name="invitemsdatagrid" datacontext="{binding}"> <datagrid.columns> <datagridcomboboxcolumn x:name="invscdropdown" displaymemberpath="codename" selectedvaluepath="codename" selectedvaluebinding="{binding codename}" /> </datagrid.columns> </datagrid> thanks always.
the first thing need set itemssource property of datagrid ienumerable.
once have done this, bind combobox or same ienumerable this:
<datagrid x:name="invitemsdatagrid" itemssource="{binding}"> <datagrid.columns> <datagridcomboboxcolumn x:name="invscdropdown" displaymemberpath="codename" selectedvaluepath="codename" selectedvaluebinding="{binding codename}"> <datagridcomboboxcolumn.elementstyle> <style targettype="{x:type combobox}"> <setter property="itemssource" value="{binding path=., relativesource={relativesource ancestortype=datagrid}}" /> </style> </datagridcomboboxcolumn.elementstyle> <datagridcomboboxcolumn.editingelementstyle> <style targettype="{x:type combobox}"> <setter property="itemssource" value="{binding path=., relativesource={relativesource ancestortype=datagrid}}" /> </style> </datagridcomboboxcolumn.editingelementstyle> </datagridcomboboxcolumn> </datagrid.columns> </datagrid> ...although doesn't make sense bind combobox , datagrid same source collection. should @ least idea.
Comments
Post a Comment