Articles in this section
Category / Section

How to populate a TreeViewAdv by using XML data with Bulletin support

1 min read

This article describes how to populate a TreeViewAdv control by using Extensible Markup Language data. As both XML and TreeViewAdv control represents the data in a hierarchical format, xml source is binded to TreeViewAdv using XmlDataProvider. Follow the below steps to populate TreeViewAdv control using xml file

Step1: Create the XML file.

XML

<Products>
  <Product Name="Tools" >
      <Feature Name="Ribbon" >
           <Feature Name="Office2010UI"/>
           <Feature Name="Data Binding Support"/>
      </Feature>
      <Feature Name="Docking Manager">
            <Feature Name="Maximization"/>
            <Feature Name="State Persistence"/>
      </Feature>
      <Feature Name="TreeView"> 
            <Feature Name="Editing"/>
            <Feature Name="Sorting"/>
       </Feature>
  </Product>
</Products>
 

 

Step2: Add the XmlDataProvider for the above XML file as follows

XAML

<XmlDataProvider Source="Data.xml" x:Key="xmlSource" XPath="Products"/>

 

Step3: Set the ItemSource property for the TreeViewAdv as follows

XAML

  <syncfusion:TreeViewAdv  ShowRootLines="False"                ItemsSource="{Binding Source={StaticResource xmlSource}, XPath=Product}" >
            <syncfusion:TreeViewAdv.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding XPath=Feature}">
                    <StackPanel Orientation="Horizontal">
                        <Image  Height="15" Source="Bullet.png"  Visibility="Visible"/>
                        <TextBlock Margin="10" Text="{Binding XPath=@Name}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
            </syncfusion:TreeViewAdv.ItemTemplate>
        </syncfusion:TreeViewAdv>

 

The above code generate the following output

D:\My KB\Vol13.4\Sprint4\Images\sshot-5.png

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied