Skip to content

Commit 64567cd

Browse files
ES-975464 - Resolve the ReadMe file length issue in this sample repository
1 parent fb0700b commit 64567cd

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
1-
# Add-wpf-treeviewadv-items-by-databinding-in-XML
2-
This session describes about how to add wpf treeviewadv items by databinding in XML
1+
# Add WPF TreeView items by databinding in XML
2+
3+
This session describes about how to add [WPF TreeView](https://help.syncfusion.com/wpf/classic/treeview/overview) (TreeViewAdv) items by databinding in XML.
4+
5+
XML file can also be used as ItemsSource for the TreeViewAdv. The following example illustrates this:
6+
7+
1. Create the XML file with the following details and name it as Data.xml:
8+
9+
``` xml
10+
11+
<Products>
12+
<Product Name="Tools" >
13+
<Feature Name="Ribbon" >
14+
<Feature Name="Office2010UI"/>
15+
<Feature Name="Data Binding Support"/>
16+
</Feature>
17+
<Feature Name="Docking Manager">
18+
<Feature Name="Maximization"/>
19+
<Feature Name="State Persistence"/>
20+
</Feature>
21+
<Feature Name="TreeView">
22+
<Feature Name="Editing"/>
23+
<Feature Name="Sorting"/>
24+
</Feature>
25+
<Feature Name="Data Editors" >
26+
<Feature Name="Watermark Text" />
27+
<Feature Name="Extended Value Scrolling" />
28+
</Feature>
29+
</Product>
30+
</Products>
31+
```
32+
33+
2. Add the XmlDataProvider for the above XML document as follows:
34+
35+
``` xml
36+
<Window.Resources>
37+
<XmlDataProvider Source="Data.xml" x:Key="xmlSource" XPath="Products"/>
38+
</Window.Resources>
39+
```
40+
41+
3. Set the `ItemsSource` property for the `TreeViewAdv` as follows:
42+
43+
``` xml
44+
<syncfusion:TreeViewAdv ItemsSource="{Binding Source={StaticResource xmlSource}, XPath=Product}" >
45+
<syncfusion:TreeViewAdv.ItemTemplate>
46+
<HierarchicalDataTemplate ItemsSource="{Binding XPath=Feature}">
47+
<TextBlock Text="{Binding XPath=@Name}" />
48+
</HierarchicalDataTemplate>
49+
</syncfusion:TreeViewAdv.ItemTemplate>
50+
</syncfusion:TreeViewAdv>
51+
```
52+
53+
4. `TreeViewAdv` will be created as follows:
54+
55+
![TreeViewAdv](TreeViewAdv_DataBinding_XML.png)

TreeViewAdv_DataBinding_XML.png

59 KB
Loading

0 commit comments

Comments
 (0)