Treeview binding in SilverLight 4
I have a dynamically generated XML file which i want to bind to a treeview control.
Here is my code<Grid x:Name="LayoutRoot" Background="White">
<sdk:TreeView x:Name="tree1" ItemsSource="{Binding ElementName=Table }" >
<sdk:HierarchicalDataTemplate>
<StackPanel>
<TextBlock Text="{Binding Skill}"/>
</StackPanel>
</sdk:HierarchicalDataTemplate>
</sdk:TreeView>
</Grid>
My XML is as follows
开发者_运维知识库<NewDataSet>
<Table>
<skillid>1</skillid>
<skill>Microsoft</skill>
<parentid>0</parentid>
<rating>0</rating>
<emailid>0</emailid>
</Table>
</NewDataSet>
It is generated through a WCF which is returning XElement.
Try loading the data into objects using XDocument
:
Sample 1: http://forums.silverlight.net/forums/t/75457.aspx
Sample 2: http://www.c-sharpcorner.com/UploadFile/dpatra/GeneratingTreeViewNodesFromXMLFileInSilverlight3Application08042009142450PM/GeneratingTreeViewNodesFromXMLFileInSilverlight3Application.aspx
精彩评论