vb.net - Silverlight TreeView Wont Populate -
i trying populate treeview in silverlight, having difficulties - appears empty.
i found tutorial (here) on how it, created new project , copied code appears, using c#, , worked perfectly. have tried incorporate project (which uses vb), doesnt work. vb code follows:
xaml
<usercontrol.resources> <common:hierarchicaldatatemplate x:key="myhierarchicaltemplate" itemssource="{binding items}" > <textblock text="{binding mystring}" /> </common:hierarchicaldatatemplate> </usercontrol.resources> <controls:treeview height="200" horizontalalignment="left" margin="280,464,0,0" name="treeview1" verticalalignment="top" width="120" itemtemplate="{staticresource myhierarchicaltemplate}" />
vb code:
public class myitem public mystring string public items observablecollection(of myitem) public sub new(byval mystring string, byval paramarray myitems() myitem) me.mystring = mystring dim itemsobservablecollection = new observablecollection(of myitem) each item myitem in myitems itemsobservablecollection.add(item) next me.items = itemsobservablecollection end sub end class
and populate it:
dim itemssource new observablecollection(of myitem) itemssource.add(new myitem("hello", new myitem("world"), new myitem("foo"))) itemssource.add(new myitem("moo", new myitem("boo", new myitem("goo")))) treeview1.itemssource = itemssource
what missing?
edit: have tried debugging project, , "itemssource" collection appears generating correctly, , being assigned treeview1.itemssource fine, nothing displaying. display binding issue?
to use bindings have expose properties- while vb.net isn't great looks items field not property in myitem class, , same mystring.
cheers -
Comments
Post a Comment