how to set checkbox in listbox for specific item in listbox C# WPF -


i have such listbox below:

    <listbox x:name="listbox" horizontalalignment="left" height="385" margin="21,138,0,0" verticalalignment="top" width="273" itemssource="{binding path=locationlist}">         <listbox.itemtemplate>             <datatemplate>                 <stackpanel orientation="horizontal">                     <button name="btndelete" click="btndelete_click" width="15" height="15" horizontalalignment="center" verticalalignment="center" verticalcontentalignment="center" horizontalcontentalignment="center" content="x" />                     <checkbox name="checkbox" />                     <textblock name="textbox" text="{binding}"/>                 </stackpanel>             </datatemplate>         </listbox.itemtemplate>     </listbox> 

and set checkbox specific item listbox.

i trying it:

    private void button4_click(object sender, routedeventargs e)     {         for(int = 0; < listbox.items.count; i++)         {             listbox.items[i].checkbox = false;         }     } 

i know doing error. cast object of item , set item's property (this checkbox) false. may correct me ? thank in advance.

edit:

before trying way:

        foreach (var item in listbox.selecteditems)         {             item.         } 

but possibilities have got standard methods: equals, gethashcode, gettype, tostring... how may refer checkbox ?

moreover supply question insight. find specific item text in line in listbox (item) , change checkbox item (same row in listbox). second logic implemented set rows selected or unselected (this trying now).

thank response.

        (int = 0; < listbox.items.count; i++)         {             var item = listbox.itemcontainergenerator.containerfromitem(listbox.items[i]) listboxitem;             var template = item.contenttemplate datatemplate;              contentpresenter mycontentpresenter = findvisualchild<contentpresenter>(item);              checkbox mycheckbox = (checkbox)template.findname("checkbox", mycontentpresenter);              mycheckbox.ischecked = true;         } 

likewise can find textblock (note, named "textbox" not "textblock")

            textblock mytextblock = (textblock)template.findname("textbox", mycontentpresenter); 

findvisualchild can found here findvisualchild reference issue