This is a migrated thread and some comments may be shown as answers.

Hierarchy Like WinForms

1 Answer 58 Views
This is a migrated thread and some comments may be shown as answers.
Erik Van Norstrand
Top achievements
Rank 1
Erik Van Norstrand asked on 07 Oct 2010, 08:18 PM

Hey all,

Does anyone know how to build a hierarchical TreeView like we have the ability to do in WinForms.

In WinForms I can do:

radTreeView1.DataSource = industryCodeList;
radTreeView1.DisplayMember = "Description";
radTreeView1.ValueMember = "IndustryCode1";
radTreeView1.ParentIDMember = "ParentIndustryCode";

I would then get a hierarchical TreeView that was really simple to use.

Erik Van Norstrand

1 Answer, 1 is accepted

Sort by
Alex Fidanov
Telerik team
answered on 08 Oct 2010, 02:46 PM
Hello Erik Van Norstrand,

If you want to display hierarchical data, you could use the HierarchicalDataTemplates to define the RadTreeView's hierarchical data structure. You can read more about them here in our help.

Below, you can find a sample code snippet of binding this control to hierarchical data

           <HierarchicalDataTemplate x:Key="SampleTemplate" 
                        ItemsSource="{Binding Sub}" >
               <TextBlock Text="{Binding Name}"/>
       <telerik:RadTreeView x:Name="radTreeView"
           ItemTemplate="{StaticResource SampleTemplate}"/>

ObservableCollection<HierarchicalClass> source = new ObservableCollection<HierarchicalClass>();
source.Add(new HierarchicalClass() { Name = "Item 1" });
radTreeView.ItemsSource = source;
where the HierarchicalClass provides the hierarchicy. More about this here.

Sincerely yours,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Erik Van Norstrand
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question