chetan Allipur

chetan Allipur

  • NA
  • 541
  • 167.7k

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" ?>
<books>
<book Title="The Elegant Universe" Author="Brian Greene" UnitPrice="15.95" Url="http://www.amazon.com/Elegant-Universe-Superstrings-Dimensions-Ultimate/dp/0393046885" ReleaseDate="02/01/1999" >
<chapter Title="Tied Up with String">
<chapter Title="Third level"></chapter>
</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>
<book Title="Dive Into Python" Author="Mark Pilgrim" UnitPrice="39.99" Url="http://www.amazon.com/Dive-Into-Python-Mark-Pilgrim/dp/1590593561" 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>
<book Title="The Selfish Gene (30th Anniversary Edition)" Author="Richard Dawkins" UnitPrice="15.95" Url="http://www.amazon.com/Selfish-Gene-Anniversary-Introduction/dp/0199291152" 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>
<book Title="The Ideological Origins of the American Revolution (Enlarged Edition)" Author="Bernard Bailyn" UnitPrice="24.00" Url="http://www.amazon.com/Ideological-Origins-American-Revolution/dp/0674443020" 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>
<book Title="Gödel, Escher, Bach: an Eternal Golden Braid" Author="Douglas R. Hofstadter" UnitPrice="20.00" Url="http://www.amazon.com/Godel-Escher-Bach-Douglas-Hofstadter/dp/B001IAM392" 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." />
</book>
</books> 
 
XAML Code :
 
<UserControl x:Class="Infragistics_SilverLight.TreeDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ig="http://schemas.infragistics.com/xaml"
mc:Ignorable="d"
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:XamTree.HierarchicalItemTemplate>
<ig:HierarchicalDataTemplate ItemsSource="{Binding Name}">
<ig:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Foreground="Gray" />
</StackPanel>
</DataTemplate>
</ig:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
</StackPanel>
</DataTemplate>
</ig:HierarchicalDataTemplate>
</ig:XamTree.HierarchicalItemTemplate>
</ig:XamTree>-->
<ig:XamTree x:Name="MyTree" ActiveItemChanged="MyTree_ActiveItemChanged_2" ItemsSource="{Binding Books}" BorderThickness="0,0,0,0" Background="#FFFFFFFF" HorizontalAlignment="Stretch">
<ig:XamTree.HierarchicalItemTemplate>
<ig:HierarchicalDataTemplate ItemsSource="{Binding Chapters}">
<ig:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Foreground="Gray" />
</StackPanel>
</DataTemplate>
</ig:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" FontWeight="Bold"/>
</StackPanel>
</DataTemplate>
</ig:HierarchicalDataTemplate>
</ig:XamTree.HierarchicalItemTemplate>
</ig:XamTree>
</Grid>
</UserControl>

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()
{
InitializeComponent();
Read();
}
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
}).ToList<Chapter>();
}
//private void MyTree_ActiveItemChanged_1(object sender, Infragistics.Controls.Menus.ActiveItemChangingEventArgs e)
//{
// //txtBox.Text += PrintLog(DataTreeStrings.XDT_ActiveNodeChanged);
//}
public void Read()
{
try
{
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)
{
throw;
}
}
private void MyTree_ActiveItemChanged_2(object sender, EventArgs e)
{
}
}
}
 

Answers (1)