Silverlight 3 RadTreeListView HierarchicalDataTemplate Question

2 posts, 0 answers
  1. Randall Anderson
    Randall Anderson avatar
    5 posts
    Member since:
    Dec 2009

    Posted 28 Dec 2010 Link to this post

    If I have the following data structure

        public class Level0
        {
            public class Level2
            {
                public string Level2Name { get; set; }
            };

            public class Level1
            {
                public string Level1Name { get; set; }
                public List<Level2> Level2List;
                public Level1()
                {
                    Level2List = new List<Level2>();
                }
            };

            public string Level0Name { get; set; }
            public List<Level1> Level1List;

            public Level0()
            {
                Level1List = new List<Level1>();
            }
        }

    And I want to define a HierarchicalDataTemplate for use in a RadTreeListView in silverlight 3.  I tried the following:

            <telerik:HierarchicalDataTemplate 
                x:Key="Level2Template" >
                <TextBlock Foreground="Yellow" Text="{Binding Level2name}"></TextBlock>
            </telerik:HierarchicalDataTemplate>

            <telerik:HierarchicalDataTemplate 
                x:Key="Level1Template" 
                ItemTemplate="{StaticResource Level2Template}"
                ItemsSource="{Binding Level2List}" >
                <TextBlock Foreground="Blue" Text="{Binding Level1Name}"></TextBlock>
            </telerik:HierarchicalDataTemplate>

            <telerik:HierarchicalDataTemplate 
                x:Key="Level0Template" 
                ItemTemplate="{StaticResource Level1Template}" 
                ItemsSource="{Binding Level1List}" >
                <TextBlock Foreground="Red" Text="{Binding Level0Name}"></TextBlock>
            </telerik:HierarchicalDataTemplate>

    then the RadTreeListView

                <telerikNavigation:RadTreeListView
                    x:Name="TheTree" 
                    ItemTemplate="{StaticResource Level0Template}" >

                    <telerikNavigation:RadTreeListView.Columns>
                        <telerikNavigation:RadColumn Header="Hierarchy" />
                    </telerikNavigation:RadTreeListView.Columns>

    </telerikNavigation:RadTreeListView>

    I tried numerous variations on this and nothing seems to work to display the tree listview.
    Can someone show me where the problem is or suggest better way.  I cant use Silveright 4 yet in this project.

    gkelly

  2. Randall Anderson
    Randall Anderson avatar
    5 posts
    Member since:
    Dec 2009

    Posted 29 Dec 2010 Link to this post

    solution: List needs to be property.  wow, i looked and looked and didnt notice this until a long time later.
  3. DevCraft banner
Back to Top