I'm currently evaluating TreeListViews from various vendors and am trying to determine if what I'm looking for is possible. We are using an MVVM model for our code. That being said I have a view model that has a collection of items. Each item has a collection of children and a collection of additional properties. Below is some sample code:
Now obviously this code isn't complete, but I wanted to give you an idea of the basic structure. Now I want to display this in a TreeListView where each row has a choice of a couple templates, one template for if its a Parent, the other if its a child. And then I want the columns to be bound to the "OtherData" in the Parents class (Meaning, I want the Header to be the "Key" in the dictionary and the data to be the "Value" of the dictionary, or some similar structure).
What I would like to be able to do is something like this:
Any insight into if this is possible with examples would be greatly appreciated. Thanks in advance.
public class PsuedoClass{ public IObservableCollection<IBaseClass> Parents { get; set; } }public class Parent : IBaseClass{ public String Name { get; set; } public IObservableCollection<IBaseClass> Children { get; set; } public IDictionary<string, string> OtherData { get; set; }}public class Child : IBaseClass{ public String Name { get; set; }}public interface IBaseClass{ String Name { get; set; }}Now obviously this code isn't complete, but I wanted to give you an idea of the basic structure. Now I want to display this in a TreeListView where each row has a choice of a couple templates, one template for if its a Parent, the other if its a child. And then I want the columns to be bound to the "OtherData" in the Parents class (Meaning, I want the Header to be the "Key" in the dictionary and the data to be the "Value" of the dictionary, or some similar structure).
What I would like to be able to do is something like this:
<UserControl ... > <UserControl.Resources> <DataTemplate x:Key="ChildItemTemplate"> <TextBlock Text="{Binding Name}"/> </DataTemplate> <HierarchicalDataTemplate x:Key="ParentItemTemplate" ItemsSource="{Binding Children}" ItemTemplate="{StaticResource ChildItemTemplate}"> <TextBlock Text="{Binding Name}"/> <SomeHowDisplayTheRestOfTheColumns/> </HierarchicalDataTemplate> </UserControl.Resources> <telerik:RadTreeListView ItemsSource="{Binding Parents}" Columns="{Binding SomePropertyThatExposesOurColumns}" ItemTemplate="{StaticResource ParentItemTemplate}"> </telerik:RadTreeListView></UserControl>Any insight into if this is possible with examples would be greatly appreciated. Thanks in advance.