Skip to content

SyncfusionExamples/Add-wpf-treeviewadv-items-by-databinding-in-XML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Add WPF TreeView Items by Databinding in XML

This session describes about how to add WPF TreeView (TreeViewAdv) items by databinding in XML.

XML file can also be used as ItemsSource for the TreeViewAdv. The following example illustrates this:

  1. Create the XML file with the following details and name it as Data.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>
        <Feature Name="Data Editors" >
            <Feature Name="Watermark Text" />
            <Feature Name="Extended Value Scrolling" />
        </Feature>
    </Product>
</Products>
  1. Add the XmlDataProvider for the above XML document as follows:
<Window.Resources>
    <XmlDataProvider Source="Data.xml" x:Key="xmlSource" XPath="Products"/>
</Window.Resources>
  1. Set the ItemsSource property for the TreeViewAdv as follows:
<syncfusion:TreeViewAdv ItemsSource="{Binding Source={StaticResource xmlSource}, XPath=Product}" >
    <syncfusion:TreeViewAdv.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding XPath=Feature}">
            <TextBlock Text="{Binding XPath=@Name}" />
        </HierarchicalDataTemplate>
    </syncfusion:TreeViewAdv.ItemTemplate>
</syncfusion:TreeViewAdv>
  1. TreeViewAdv will be created as follows:

Databinding TreeViewAdv using XML

About

This session describes about how to add wpf treeviewadv items by databinding in XML

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages