Hi,
I am having one xml file i need to bind that xml file to xamwebtree dynamically. For that the below mentioned is xaml page:
<
="Infragistics_XamWebTree.MainPage"
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
="http://schemas.microsoft.com/winfx/2006/xaml"
="http://schemas.microsoft.com/expression/blend/2008"
="http://schemas.openxmlformats.org/markup-compatibility/2006"
="d"
="400">
="White">
="Stretch"
>
</
And the below mentioned is the xaml.cs page
XDocument
categoriesXML = XDocument.Load("Products.xml");
categories = LoadDimensions(categoriesXML.Element(
"Root"));
igWebTree.ItemsSource = categories;
element)
{
element.Elements().Elements()
Products()
Name = Products.Attribute(
).Value,
SubCategories =
.LoadDimensions(Products)
}).ToList();
}
And the below mentioned is the Products.xml file
<?
xml version="1.0" encoding="utf-8" ?>
<Root>
dimension name="Products">
member name="Soap" FullPath="Products.Soap" isleaf="false">
member name="Dove" FullPath="Products.Soap.Dove" isleaf="true"/>
member name="Lux" FullPath="Products.Soap.Lux" isleaf="true"></member>
member name="Pears" FullPath="Products.Soap.Pears" isleaf="true"></member>
member>
member name="Cleaning" FullPath="Products.Cleaning" isleaf="true">
member name="Food" FullPath="Products.Food" isleaf="true"></member>
dimension>
Root>
I am getting the output like this:
Infragistics_Xamwebtree.Products
with checkboxes before each node like this. Let me know what i need to do. Thanks in Advance.
Regards,
Amarendra.
You are binding to a Products object and the tree is trying to get the string representation of that object for each item.
You should set the ItemTemplate to show the field off your data object that you want visible.
<ig:XamWebTree.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="HelloWorld"></TextBlock>
<TextBlock Text="{Binding Age}"></TextBlock>
</StackPanel>
</DataTemplate>
</ig:XamWebTree.ItemTemplate>
If you are showing hierarchial data then you would want to use the HierarchicalDataTemplate
<ig:XamWebTree.HierarchicalItemTemplate>
<ig:HierarchicalDataTemplate>
<ig:HierarchicalDataTemplate.Template>
<TextBlock Text="ForChildrenOfThisObject"></TextBlock>
</ig:HierarchicalDataTemplate.Template>
<ig:HierarchicalDataTemplate.ItemTemplate><!-- This template would be used by your products-->
</ig:HierarchicalDataTemplate.ItemTemplate>
</ig:HierarchicalDataTemplate>
</ig:XamWebTree.HierarchicalItemTemplate>
Thank you. But i am having one more issue if i want to bind an XML which is having many nested levels. How many nested levels will be there i will not be knowing. In that case how to add HierarchicalDataTemplate dynamically. Can you show me a sample code for this?