Hierarchy Like WinForms

2 posts, 0 answers
  1. Erik Van Norstrand
    Erik Van Norstrand avatar
    3 posts
    Member since:
    Apr 2010

    Posted 07 Oct 2010 Link to this post

    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

  2. Alex Fidanov
    Alex Fidanov avatar
    637 posts

    Posted 08 Oct 2010 Link to this post

    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
Back to Top