This question is locked. New answers and comments are not allowed.
Hi
I have a class representing a node in a tree:
How do you create a HierarchicalDataTemplate so that it generates a recursive tree. Bellow is the sample data:
Thanks for your help!
I have a class representing a node in a tree:
public class NavigationItem{ public string Title { get; set; } public string Icon { get; set; } public string SomeUrl { get; set; }
public ObservableCollection<NavigationItem> Items { get; set; }}How do you create a HierarchicalDataTemplate so that it generates a recursive tree. Bellow is the sample data:
public class NavigationItemCollection{ public ObservableCollection<NavigationItem> Items; public NavigationItemCollection() { Items = new ObservableCollection<NavigationItem>(); Items.Add(new NavigationItem() { Title = "Node 1", Icon = "Icon1.png", SomeUrl = "/test1", Items = new ObservableCollection<NavigationItem>(){ new NavigationItem() { Title = "SubNode 1", Icon = "SubIcon1.png", SomeUrl = "/subtest1" }, new NavigationItem() { Title = "SubNode 2", Icon = "SubIcon2.png", SomeUrl = "/subtest1" } } }); Items.Add(new NavigationItem() { Title = "Node 2", Icon = "Icon2.png", SomeUrl = "/test2" }); Items.Add(new NavigationItem() { Title = "Node 3", Icon = "Icon3.png", SomeUrl = "/test3" }); }}Thanks for your help!