How to get the Infragistics tree view in using silverlightCAchetan Allipur9yAsked Mar 26, 2017, 8:21 PM EDT2 answersShareLinkedInXCopy linkSaveHow to get Infragistics Tree View from XML file using Silverlight. Please Send the code Help me.
How to get the Infragistics tree view in using silverlightCAchetan Allipur9yAsked Mar 26, 2017, 8:21 PM EDT2 answersShareLinkedInXCopy linkSaveHow to get Infragistics Tree View from XML file using Silverlight. Please Send the code Help me.
Suvendu Shekhar GiriRank #546 · 4.4K reputation9y agoPosted Mar 26, 2017, 11:41 PM EDT0Anything you have tried so far?0
CAchetan AllipurRank #2,527 · 554 reputation9y agoPosted Mar 27, 2017, 12:42 AM EDT0YesI will send the code This is for xaml xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="700" Title="ViewModelBinding Page" xmlns:framework="clr-namespace:Infragistics.Samples.Framework;assembly=Infragistics.Samples.Framework" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:res="clr-namespace:Infragistics_SilverLight.Resources"> This is for Code-Behind using Infragistics.Controls.Menus;using System;using System.Collections.Generic;using System.ComponentModel;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.Shapes;using System.Xml.Linq;using Infragistics.Controls.Menus;using Infragistics.Samples.Framework;using Infragistics.Samples.Shared.DataProviders;using Infragistics.Samples.Shared.Extensions;using Infragistics.Samples.Shared.Models;using System.Windows.Data.XmlDataProvider;namespace Infragistics_SilverLight{ public partial class Tree : UserControl { public Tree() { InitializeComponent(); this.Loaded += OnSampleLoaded; this.MyTree.Loaded += new RoutedEventHandler(dataTree_Loaded); } void dataTree_Loaded(object sender, RoutedEventArgs e) { XamTree tree = (XamTree)sender; if (tree.XamTreeItems.Count() > 0) { tree.XamTreeItems[0].IsExpanded = true; } } private BookDataSource viewModel; void OnSampleLoaded(object sender, RoutedEventArgs e) { this.viewModel = new BookDataSource(); this.DataContext = this.viewModel; this.DownloadDataSource(); } private XmlDataProvider xmlDataProvider; /// /// This method is used for downloading the sample's data source. To support localization we created a custom helper class. /// void DownloadDataSource() { xmlDataProvider = new XmlDataProvider(); xmlDataProvider.GetXmlDataCompleted += new EventHandler(xmlDataProvider_GetXmlDataCompleted); xmlDataProvider.GetXmlDataAsync("Books.xml"); // xml file name } void xmlDataProvider_GetXmlDataCompleted(object sender, GetXmlDataCompletedEventArgs gxdcea) { XDocument doc = gxdcea.Result; if (doc != null) { 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) }); this.viewModel.Books = dataSource.ToList(); } if (this.MyTree.XamTreeItems.Count() > 0) { this.MyTree.XamTreeItems[0].IsExpanded = true; } } public class Book:INotifyPropertyChanged { 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 Chapters { get; set; } } public class Chapter : INotifyPropertyChanged { public string Title { get; set; } } private IEnumerable GetChapters(XElement parent) { return (from d in parent.Descendants("chapter") select new Chapter { Title = d.Attribute("Title").Value }).ToList(); } } public class BookDataSource : ObservableModel { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public BookDataSource() { } private IEnumerable books; public IEnumerable Books { get { return this.books; } set { if (this.books != value) { this.books = value; this.OnPropertyChanged("Books"); } } } }}0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suvendu Shekhar GiriRank #546 · 4.4K reputationPosted Mar 26, 2017, 11:41 PM EDT
chetan AllipurRank #2,527 · 554 reputationPosted Mar 27, 2017, 12:42 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts