I thought I'd provide you guys with my c# source code for my sample data just to make it easier for you
Don't worry about the .Web project since i haven't implemented anything yet.
I can get the first level of data to appear, but not the second level for some reason
<
UserControl
x:Class
=
"TreeListViewPrototype.MainPage"
xmlns:telerikControls
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:telerikDataView
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerikInput
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
xmlns:telerikNavigation
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:local
=
"clr-namespace:TreeListViewPrototype"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
UserControl.Resources
>
<
local:HierarchyConverter
x:Key
=
"HierarchyConverter"
/>
<
telerikControls:HierarchicalDataTemplate
x:Key
=
"RootItem"
ItemsSource
=
"{Binding Converter={StaticResource HierarchyConverter}}"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
telerikControls:HierarchicalDataTemplate
>
<
DataTemplate
x:Key
=
"DataTemplate1"
>
<
Grid
>
<
TextBlock
Text
=
"{Binding Name,Mode=OneWay}"
TextWrapping
=
"Wrap"
/>
</
Grid
>
</
DataTemplate
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
telerikNavigation:RadTreeListView
x:Name
=
"protoTreeListView"
SelectionMode
=
"Extended"
ItemTemplate
=
"{StaticResource RootItem}"
ItemsSource
=
"{Binding Converter={StaticResource HierarchyConverter}}"
SelectedValuePath
=
"Name"
SelectionChanged
=
"protoTreeListView_SelectionChanged"
>
<
telerikNavigation:RadTreeListView.Columns
>
<
telerikNavigation:RadColumn
x:Name
=
"name"
Header
=
"Bond Name"
CellTemplate
=
"{StaticResource DataTemplate1}"
/>
</
telerikNavigation:RadTreeListView.Columns
>
</
telerikNavigation:RadTreeListView
>
</
Grid
>
</
UserControl
>
using
System;
using
System.Collections.Generic;
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.Collections.ObjectModel;
using
Telerik.Windows.Controls;
using
System.ComponentModel;
using
System.Windows.Data;
using
System.Globalization;
using
Telerik.Windows.Data;
namespace
TreeListViewPrototype
{
public partial class MainPage : UserControl
{
public MainPage()
{
ObservableCollection<Bond> data = new ObservableCollection<Bond>();
Bond bond1 = new Bond("FirstBond");
Bond bond2 = new Bond("SecondBond");
bond1.history.Add(
new History(1.00, "Joe"));
bond1.history.Add(
new History(2.00, "Bob"));
bond1.history.Add(
new History(3.00, "Mary"));
bond1.history.Add(
new History(4.00, "Alex"));
bond2.history.Add(
new History(10.00, "Caleb"));
bond2.history.Add(
new History(20.00, "Kamilla"));
bond2.history.Add(
new History(30.00, "Justin"));
bond2.history.Add(
new History(40.00, "Mike"));
InitializeComponent();
data.Add(bond1);
data.Add(bond2);
this.protoTreeListView.ItemsSource = data;
}
private void protoTreeListView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
string something;
something = sender.GetType().ToString();
}
}
public class Bond : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string name;
public string Name
{
get
{
return this.name;
}
set
{
if (this.name != value)
{
this.name = value;
this.OnPropertyChanged("Name");
}
}
}
public Bond(string name)
{
this.Name = name;
this.history = new ObservableCollection<History>();
}
public ObservableCollection<History> history
{
get;
set;
}
protected void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class History : INotifyPropertyChanged
{
public double Price { get; set; }
public string Buyer { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public History(double price, string buyer)
{
this.Price = price;
this.Buyer = buyer;
}
protected void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class HierarchyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// We are binding an item
Bond item = value as Bond;
if (item != null)
{
return item.history.Where(x => x != null);
}
// We are binding the treeview
ObservableCollection<Bond> items = value as ObservableCollection<Bond>;
if (items != null)
{
return items.Where(x=> x.Name == "FirstBond");
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}