开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜