c# - Binding Dictionary<string,List<Class>> to multiple TreeViewItem -




so i've got data want store in treeview , have working 2 branches i'm stuck on getting more that. think dictionary best cause it'll easiest store ids in key when come add in 'sanity checks'

how want data presented:

--internet checks ----- 'date, message, status' --------- 'details' --server checks ----- 'date, message, status' --------- 'details' --sanity checks ----- 'date, message, status' --------- 'details' --------- 'error1' --------- 'error2' --------- 'error3' --------- 'etc' --etc 

and here's how looks @ moment

--internet checks ----- 'date, message, status' --server checks ----- 'date, message, status' --sanity checks ----- 'date, message, status' --etc 

so here's how have xaml @ moment:

<treeview name="treeview1" itemssource="{binding items}">                 <treeview.itemtemplate>                     <hierarchicaldatatemplate itemssource="{binding path=value.subitems}">                         <textblock text="{binding value.text}" />                         <hierarchicaldatatemplate.itemtemplate>                             <datatemplate>                                 <textblock text="{binding path=value.text}"/>                             </datatemplate>                         </hierarchicaldatatemplate.itemtemplate>                     </hierarchicaldatatemplate>                 </treeview.itemtemplate>             </treeview> 

here menuitem class:

public class menuitem     {         public menuitem()         {             this.subitems = new dictionary<int, menuitem>();         }          public dictionary<int, menuitem> subitems { get; set; }          public string text { get; set; }     } 

and here how i'm filling in dictionary:

public dictionary<int, menuitem> fill(string name, dictionary<int, menuitem> root, list<healthcheckhourmodel> list)         {             root.add(nextnum, new menuitem { text = name + " checks"});             foreach (healthcheckhourmodel hchm in list)             {                 if (hchm.message.contains(name))                 {                     root[nextnum].subitems.add(hchm.id, new menuitem { text = hchm.starttime + " " + hchm.message });                     root[nextnum].subitems[hchm.id].subitems.add(-111, new menuitem { text = hchm.details });                 }             }             nextnum--;             return root;         } 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -