c# - WPF set selected item in listview when combobox is selected -
i have following listview
:
<listview grid.row="1" itemssource="{binding transducers}" selecteditem="{binding selectedtransducer}"> <listview.view> <gridview> <gridviewcolumn header="id" displaymemberbinding="{binding labid}"/> <gridviewcolumn header="manufacturer" displaymemberbinding="{binding manufacturer}"/> <gridviewcolumn header="channel"> <gridviewcolumn.celltemplate> <datatemplate> <combobox itemssource="{binding datacontext.channels, elementname=maininterface}" selecteditem="{binding channel, mode=twoway}" selectedvalue="{binding channel.id}" selectedvaluepath="id"/> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> </gridview> </listview.view> </listview>
it has few text items , combobox. after change combobox value, want selected item, should item combobox interacted with. however, when interact combobox on item , nothing else item, not become selected. how set selected item when interact combobox of item?
filippo's solution close did not work in case. ended using tryfindparent<t>()
function mentioned, code looked this:
private void combobox_dropdownclosed(object sender, system.eventargs e) { listview.selecteditem = null; var newselecteditem = (sender combobox).tryfindparent<listviewitem>(); newselecteditem.isselected = true; }
where listview
name of listview.
Comments
Post a Comment