How to find sibling of a control that raised an event in DataGrid WPF -
i have datagrid whole columns given below.
<my:datagrid.columns> <my:datagridtemplatecolumn header="last name" minwidth="160" sortmemberpath="[last_name]"> <my:datagridtemplatecolumn.celltemplate > <datatemplate> <textblock name="lbllastname" padding="5" text="{binding [last_name]}" /> </datatemplate> </my:datagridtemplatecolumn.celltemplate> </my:datagridtemplatecolumn> <my:datagridtemplatecolumn header="new age group" isreadonly="true" minwidth="130"> <my:datagridtemplatecolumn.celltemplate> <datatemplate> <combobox selectedvalue="{binding agegroupid}" displaymemberpath="agegroupname" itemssource="{binding}" name="ddlnewagegroup" loaded="ddlnewagegroup_loaded"/> </datatemplate> </my:datagridtemplatecolumn.celltemplate> </my:datagridtemplatecolumn> <my:datagridtemplatecolumn header="update" minwidth="75" width="100"> <my:datagridtemplatecolumn.celltemplate> <datatemplate> <button content="update" name="btnupdate" click="btnupdate_click"/> </datatemplate> </my:datagridtemplatecolumn.celltemplate> </my:datagridtemplatecolumn> </my:datagrid.columns> on btnupdate_click event want value has been set on ddlnewagegroup
but dont know how find combobox on button click event in wpf. using datatables bind grids.
(e.originalsource button).datacontext should object binded row, should have agegroupid property (as seen combobox.selectedvalue), , it's collection (as seen combobox.itemssource). may find use agegroupname way:
private void grid_click(object sender, routedeventargs e) { var row = (e.originalsource button).datacontext %yourdatatype%; var agegroupname = row.first(item => item.agegroupid == row.agegroupid).agegroupname; // todo: need "agegroupname". } ps. please set combobox.selectedvaluepath agegroupid: without it, combobox.selectedvalue equal whole record, not id
Comments
Post a Comment