c# - Get ListViewItem control in CodeBehind -


i have listview , each item has checkbox control part of itemtemplate.

<listview x:name="tasklistview" grid.row="2" borderthickness="0" margin="30,0,0,0" itemssource="{binding childitems}">         <listview.itemtemplate>             <datatemplate>                 <grid>                     <grid.columndefinitions>                         <columndefinition width="25"/>                         <columndefinition width="290"/>                         <columndefinition width="*"/>                     </grid.columndefinitions>                     <checkbox grid.column="0" horizontalalignment="center"></checkbox>                     <textblock text="{binding name}" maxwidth="270" grid.column="1" margin="0,0,10,0"/>                     <combobox selecteditem="{binding dependenttask, mode=twoway}"                                grid.column="2"                               margin="0,3,0,3"                               itemssource="{binding dependenttasks, converter={staticresource addemptyitemconverter}}"                                horizontalalignment="left"                               minwidth="150"                               displaymemberpath="projectiontasklink.name"/>                 </grid>             </datatemplate>         </listview.itemtemplate>     </listview> 

there parent listview has checkbox well. when parent checkbox checked, want check checkboxes in listviewitems. how can hold of in codebehind can set them checked or unchecked depending on parent condition?

thanks.

edit: here full xaml:

<grid margin="0,10,0,0">     <grid.rowdefinitions>         <rowdefinition height="25"/>         <rowdefinition height="20"/>         <rowdefinition height="*"/>     </grid.rowdefinitions>     <grid grid.row="0">         <grid.columndefinitions>             <columndefinition width="25"/>             <columndefinition width="400"/>             <columndefinition width="35"/>             <columndefinition width="35"/>         </grid.columndefinitions>         <checkbox horizontalalignment="center" grid.column="0" checked="checkbox_checked"/>         <textblock text="{binding name}" grid.column="1"/>         <textblock text="loops " grid.column="2" textalignment="center"/>         <textbox text="{binding scenarios}" grid.column="3"/>     </grid>     <textblock visibility="{binding containsprojectiontasks, converter={staticresource booltovisibilityconverter}}"                     horizontalalignment="left"                     width="450"                     textalignment="right"                     verticalalignment="bottom"                     grid.row="1"                     text="task dependencies"                     background="white"/>     <listview x:name="tasklistview" grid.row="2" borderthickness="0" margin="30,0,0,0" itemssource="{binding childitems}">         <listview.itemtemplate>             <datatemplate>                 <grid>                     <grid.columndefinitions>                         <columndefinition width="25"/>                         <columndefinition width="290"/>                         <columndefinition width="*"/>                     </grid.columndefinitions>                     <checkbox grid.column="0" horizontalalignment="center"></checkbox>                     <textblock text="{binding name}" maxwidth="270" grid.column="1" margin="0,0,10,0"/>                     <combobox selecteditem="{binding dependenttask, mode=twoway}"                                grid.column="2"                               margin="0,3,0,3"                               itemssource="{binding dependenttasks, converter={staticresource addemptyitemconverter}}"                                horizontalalignment="left"                               minwidth="150"                               displaymemberpath="projectiontasklink.name"/>                 </grid>             </datatemplate>         </listview.itemtemplate>     </listview> </grid> 

have elements of childitems implement inotifypropertychanged.

add property elements called ischecked, raises notifypropertychangedevent in setter.

bind listviewitem's checkbox ischecked property

i assume handling checked event on parent checkbox. need add codebehind method:

(foreach yourtype item in childitems)     item.ischecked = parentcheckbox.ischecked; 

or try (where parentcheckboxname x:name of master checkbox.

<checkbox ischecked="{binding path=ischecked, elementname=parentcheckboxname}" grid.column="0" horizontalalignment="center" /> 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -