<telerikNavigation:RadTreeView x:Name="RadTree" IsLoadOnDemandEnabled="True" LoadOnDemand="RadTree_LoadOnDemand">
<telerikNavigation:RadTreeView.ItemTemplate>
<core:HierarchicalDataTemplate ItemsSource="{Binding ChildrenNodes}">
<TextBlock Text="{Binding Name}" Margin="5,0" />
</core:HierarchicalDataTemplate>
</telerikNavigation:RadTreeView.ItemTemplate>
</telerikNavigation:RadTreeView>
code behind:
//in the load method
ObservableCollection <TreeNode> Nodes = new ObservableCollection<TreeNode>();
//populate a bunch of node objects
RadTree.ItemsSource = Nodes;
private
void RadTree_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
TreeNode node = item.Item as TreeNode;
TreeNode childNode = new TreeNode();
childNode.NodeId = 55;
childNode.Name =
"I'm a Child!";
node.ChildrenNodes =
new ObservableCollection<TreeNode>();
node.ChildrenNodes.Add(childNode);
}
and simple biz obj
public class TreeNode : INotifyPropertyChanged
{
private int nodeId;
private string name;
public event PropertyChangedEventHandler PropertyChanged;
private ObservableCollection<TreeNode> _children;
public ObservableCollection<TreeNode> ChildrenNodes...
public int NodeId...
public string Name...
private void OnPropertyChanged(string p)...
}
I've tried to make it as simple as possible but I can only populate the root nodes, not the ChildrenNodes. I think the problem is somewhere in my LoadOnDemand event handler.
Thanks
