Wednesday, 15 February 2012

c# - Treeview WPF Error 26 ItemTemplate and Item Tamplate Selector are ignored for items -



c# - Treeview WPF Error 26 ItemTemplate and Item Tamplate Selector are ignored for items -

i have next code append items treeview, mytreeviewitem beingness custom class inherits treeviewitem:

foreach ( site site in sitemanager.sitelist.tolist()){ mytreeviewitem historicalitem = new mytreeviewitem(); historicalitem.leftheader.content = site.profile.username; historicalitem.btmsubheader3.content = string.format("total: {0, 8:n0}", site.total); historicalitem.itemssource = site.historicallist; historicaltree.items.add(historicalitem); }

and next relevant xaml code::

<datatemplate x:key="historicaltemplate"> <stackpanel orientation="horizontal"> <label content="{binding path=timestamp}" fontfamily="consolas" width="80" horizontalcontentalignment="right" verticalcontentalignment="center" height="30"/> <label content="{binding path=headertext}" fontfamily="consolas" width="500" horizontalcontentalignment="left" verticalcontentalignment="center" height="30"/> <label content="{binding path=total}" fontfamily="consolas" width="250" horizontalcontentalignment="right" verticalcontentalignment="center" height="30"/> </stackpanel> </datatemplate> <treeview itemssource="{binding }" itemtemplate="{staticresource historicaltemplate}" margin="0,10,0,0" name="historicaltree" background="{x:null}" borderbrush="{x:null}" fontfamily="consolas" fontsize="12"> </treeview>

now problem when run program, template not applied , error 26: itemtemplate ignored. not sure why beingness ignored or how prepare it. ideas?

c# wpf

No comments:

Post a Comment