refresh function for treeview wpf c# -


i have treeview:

<treeview name="files" margin="0,0,569,108" grid.row="1" itemssource="{binding s1}" >     <treeview.itemtemplate>         <hierarchicaldatatemplate itemssource="{binding members}" >             <stackpanel orientation="horizontal">                 <image source="folder.jpg" margin="0,0,5,0" width="20" height="20"/>                 <textblock text="{binding name}" />                 <textblock text=" ["/>                 <textblock text="{binding count}"/>                 <textblock text="]"/>             </stackpanel>             <hierarchicaldatatemplate.itemtemplate>                 <datatemplate>                     <checkbox content="{binding content}" checked="filecheckbox_checked" unchecked="filecheckbox_unchecked" />                 </datatemplate>             </hierarchicaldatatemplate.itemtemplate>         </hierarchicaldatatemplate>      </treeview.itemtemplate> </treeview>                     

and have function of select all:

private void allfilescheckbox_checked(object sender, routedeventargs e) {     foreach (site item in (files.items).sourcecollection observablecollection<site>)     {         foreach (checkbox c in item.members)             c.ischecked = true;     }    } 

the problem tree doesn't refresh after function...

how can refresh it?

answer:

add ischecked="{binding ischecked}" in data template

you update itemssource property. implementation of method this:

 private void allfilescheckbox_checked(object sender, routedeventargs e)     {          foreach (site item in (files.items).sourcecollection observablecollection<site>)         {             foreach (checkbox c in item.members)                 c.ischecked = true;         }          //update tree view         var temp = mytreeview.itemssource         mytreeview.itemssource = null;         mytreeview.itemssource = temp;     } 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -