chetan Allipur

chetan Allipur

  • 1.4k
  • 541
  • 82.5k

I want sub directories In my code inTreeview Infragistics

Mar 28 2017 3:14 AM
How to get the Sub directories also In my code. I am using Silverlight Application.Please send me the code.
XML File:
<?xml version="1.0" encoding="utf-8" ?>
<book Title="The Elegant Universe" Author="Brian Greene" UnitPrice="15.95" Url="" ReleaseDate="02/01/1999" >
<chapter Title="Tied Up with String">
<chapter Title="Third level"></chapter>
<chapter Title="Space, Time, and the Eye of the Beholder" />
<chapter Title="Of Warps and Ripples" />
<chapter Title="Microscopic Weirdness" />
<chapter Title="The Need for a New Theory: General Relativity vs. Quantum Mechanics" />
<chapter Title="Nothing but Music: The Essentials of Superstring Theory" />
<chapter Title="The &quot;Super&quot; in Superstrings" />
<chapter Title="More Dimensions Than Meet the Eye" />
<chapter Title="The Smoking Gun: Experimental Signatures" />
<chapter Title="Quantum Gravity" />
<chapter Title="Tearing the Fabric of Space" />
<chapter Title="Beyond Strings: In Search of M-Theory" />
<chapter Title="Black Holes: A String/M-Theory Perspective" />
<chapter Title="Reflections on Cosmology" />
<chapter Title="Prospects" />
<book Title="Dive Into Python" Author="Mark Pilgrim" UnitPrice="39.99" Url="" ReleaseDate="07/19/2004" >
<chapter Title="Installing Python" />
<chapter Title="Your First Python Program" />
<chapter Title="Native Datatypes" />
<chapter Title="The Power of Introspection" />
<chapter Title="Objects and Object-Orientation" />
<chapter Title="Exceptions and File Handling" />
<chapter Title="Regular Expressions" />
<chapter Title="HTML Processing" />
<chapter Title="XML Processing" />
<chapter Title="Scripts and Streams" />
<chapter Title="HTTP Web Services" />
<chapter Title="SOAP Web Services" />
<chapter Title="Unit Testing" />
<chapter Title="Test-First Programming" />
<chapter Title="Refactoring" />
<chapter Title="Functional Programming" />
<chapter Title="Dynamic Functions" />
<chapter Title="Performance Tuning" />
<book Title="The Selfish Gene (30th Anniversary Edition)" Author="Richard Dawkins" UnitPrice="15.95" Url="" ReleaseDate="05/25/2006" >
<chapter Title="Why are people?" />
<chapter Title="The replicators" />
<chapter Title="Immortal coils" />
<chapter Title="The gene machine" />
<chapter Title="Aggression: stability and the selfish machine" />
<chapter Title="Genesmanship" />
<chapter Title="Family planning" />
<chapter Title="Battle of the generations" />
<chapter Title="Battle of the sexes" />
<chapter Title="You scratch my back, I'll ride on yours" />
<chapter Title="Memes: the new replicators" />
<chapter Title="Nice guys finish first" />
<chapter Title="The long reach of the gene" />
<book Title="The Ideological Origins of the American Revolution (Enlarged Edition)" Author="Bernard Bailyn" UnitPrice="24.00" Url="" ReleaseDate="03/01/1992" >
<chapter Title="The Literature of Revolution" />
<chapter Title="Sources and Traditions" />
<chapter Title="Power and Liberty: A Theory of Politics" />
<chapter Title="The Logic of Rebellion" />
<chapter Title="Transformation" />
<chapter Title="The Contagions of Liberty" />
<chapter Title="Fulfillment: A Commentary on the Constitution" />
<book Title="Gödel, Escher, Bach: an Eternal Golden Braid" Author="Douglas R. Hofstadter" UnitPrice="20.00" Url="" ReleaseDate="01/01/1999" >
<chapter Title="The MU-puzzle." />
<chapter Title="Meaning and Form in Mathematics." />
<chapter Title="Figure and Ground." />
<chapter Title="Consistency, Completeness, and Geometry." />
<chapter Title="Recursive Structures and Processes." />
<chapter Title="The Location of Meaning." />
<chapter Title="The Propositional Calculus." />
<chapter Title="Typographical Number Theory." />
<chapter Title="Mumon and Gödel." />
<chapter Title="Levels of Description, and Computer Systems." />
<chapter Title="Brains and Thoughts." />
<chapter Title="Minds and Thoughts." />
<chapter Title="BlooP and FlooP and GlooP." />
<chapter Title="On Formally Undecidable Propositions of TNT and Related Systems." />
<chapter Title="Jumping out of the System." />
<chapter Title="Self-Ref and Self-Rep." />
<chapter Title="Church, Turing, Tarski, and Others." />
<chapter Title="Artificial Intelligence: Retrospects." />
<chapter Title="Artificial Intelligence: Prospects." />
<chapter Title="Strange Loops, Or Tangled Hierarchies." />
XAML Code :
<UserControl x:Class="Infragistics_SilverLight.TreeDemo"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<!--<ig:XamTree x:Name="MyTree" ItemsSource="{Binding Books}" BorderThickness="0,0,0,0" Background="#FFFFFFFF" HorizontalAlignment="Stretch">
<ig:HierarchicalDataTemplate ItemsSource="{Binding Name}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Foreground="Gray" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
<ig:XamTree x:Name="MyTree" ActiveItemChanged="MyTree_ActiveItemChanged_2" ItemsSource="{Binding Books}" BorderThickness="0,0,0,0" Background="#FFFFFFFF" HorizontalAlignment="Stretch">
<ig:HierarchicalDataTemplate ItemsSource="{Binding Chapters}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Foreground="Gray" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" FontWeight="Bold"/>

Code-Behind File: 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Resources;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;
namespace Infragistics_SilverLight
public partial class TreeDemo : UserControl
public TreeDemo()
public class Book
public string Author { get; set; }
public string Title { get; set; }
public string UnitPrice { get; set; }
public string Url { get; set; }
public decimal Price { get; set; }
public string ReleaseDate { get; set; }
public IEnumerable<Chapter> Chapters { get; set; }
public XNode node { get; set; }
public class Chapter
public string Title { get; set; }
public string Author { get; set; }
public string UnitPrice { get; set; }
public XNode node { get; set; }
private IEnumerable<Chapter> GetChapters(XElement parent)
return (from d in parent.Descendants("chapter")
select new Chapter
Title = d.Attribute("Title").Value,
node = d
//private void MyTree_ActiveItemChanged_1(object sender, Infragistics.Controls.Menus.ActiveItemChangingEventArgs e)
// //txtBox.Text += PrintLog(DataTreeStrings.XDT_ActiveNodeChanged);
public void Read()
XDocument doc = XDocument.Load("Books.xml");
var dataSource = (from d in doc.Descendants("book")
where (d.Descendants("chapter") != null && d.Descendants("chapter").Count() > 0)
select new Book
Author = d.Attribute("Author").Value,
Title = d.Attribute("Title").Value,
UnitPrice = d.Attribute("UnitPrice").Value,
Url = d.Attribute("Url").Value,
ReleaseDate = d.Attribute("ReleaseDate").Value,
Chapters = this.GetChapters(d),
node = d
this.MyTree.ItemsSource = dataSource.ToList();
catch (Exception)
private void MyTree_ActiveItemChanged_2(object sender, EventArgs e)

Answers (1)