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

HierarchicalDataTemplate Not working in RadTreeview

2 Answers 168 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Zacharias Karasavvas
Top achievements
Rank 1
Zacharias Karasavvas asked on 04 Aug 2010, 01:22 PM
Hi ,
I'm using C#,VS2010 and the latest rad controls.
I have a radoutlook bar and inside I have a treeview. I'm retrieving from my webservice an xml file and populate the treeview with the hierarchy.
My code is working perfect and it populates correctly my data and the hierarchy if I have the below in my XAML.

  <layoutToolkit:Accordion Grid.Row="2" x:Name="MyAccordion"  Width="210" SelectionMode="ZeroOrOne" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                         SelectionSequence="CollapseBeforeExpand" >
            <layoutToolkit:AccordionItem x:Name="BrowsersItem" Header="Browsers" Background="LightGray" >
                <control:TreeView x:Name="Browsers" Height="Auto" Width="200" Background="LightGray"  DataContext="{Binding Path=Items}">
                    <control:TreeView.ItemTemplate>
                        <c:HierarchicalDataTemplate ItemsSource="{Binding Path=Items}" >
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                <Image Source="{Binding Path=Image}" />
                                <TextBox Text="{Binding Path=Selection_Name}"  IsReadOnly="True"  >
                                    <ToolTipService.ToolTip>
                                        <ToolTip Content="{Binding Path=Selection_Name}">
                                            <ToolTip.Background>
                                                <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
                                                    <GradientStop Color="Yellow" Offset="0.8"/>
                                                    <GradientStop Color="White" Offset="0"/>
                                                </LinearGradientBrush>
                                            </ToolTip.Background>
                                        </ToolTip>
                                    </ToolTipService.ToolTip>
                                </TextBox>
                            </StackPanel>
                        </c:HierarchicalDataTemplate>
                    </control:TreeView.ItemTemplate>
                </control:TreeView>

            </layoutToolkit:AccordionItem>
            <layoutToolkit:AccordionItem Header="My Folders" Background="LightGray">

            </layoutToolkit:AccordionItem>
            <layoutToolkit:AccordionItem Header="Company Filing" Background="LightGray">

            </layoutToolkit:AccordionItem>
        </layoutToolkit:Accordion>

The above is populating the data and that means that my code is working fine.
But when I try to use the Radtreeview I cannot populate the hierarchy.
In my XAML I have the below.

   <telerik:RadOutlookBar HorizontalAlignment="Stretch" Name="radOutlookBar1" VerticalAlignment="Stretch" Grid.RowSpan="4" Margin="0,23,0,0" >

            <telerik:RadOutlookBarItem Header="Browsers" FontWeight="Bold"
                                Icon="../Images/Mail-32.png"
                                SmallIcon="../Images/Mail-32.png"
                                Tag="Browsers" >

                <telerik:RadTreeView x:Name="Browsers_TreeView" IsLineEnabled="True"  ItemsSource="{Binding Path=Items}" IsExpandOnDblClickEnabled="True" >
                    <telerik:RadTreeView.ItemTemplate>
                        <c:HierarchicalDataTemplate ItemsSource="{Binding Path=Items}" >
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                <Image Source="{Binding Path=Image}" />
                                <TextBox Text="{Binding Path=Selection_Name}"  IsReadOnly="True"  Style="{StaticResource OnlySelectedTextBox}" >
                                    <ToolTipService.ToolTip>
                                        <ToolTip Content="{Binding Path=Selection_Name}">
                                            <ToolTip.Background>
                                                <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
                                                    <GradientStop Color="Yellow" Offset="0.8"/>
                                                    <GradientStop Color="White" Offset="0"/>
                                                </LinearGradientBrush>
                                            </ToolTip.Background>
                                        </ToolTip>
                                    </ToolTipService.ToolTip>
                                </TextBox>
                            </StackPanel>

                        </c:HierarchicalDataTemplate>
                    </telerik:RadTreeView.ItemTemplate>
                    
                    
                    
                </telerik:RadTreeView>



            </telerik:RadOutlookBarItem>
            <telerik:RadOutlookBarItem Header="My Folders" FontWeight="Bold"
                                Icon="../Images/Folder-32.png"
                                SmallIcon="../Images/Folder-32.png"
                                Tag="My Folders" >

                <telerik:RadTreeView x:Name="MyFolders_TreeView" IsLineEnabled="True">
                    <telerik:RadTreeViewItem Header="myfolders">

                    </telerik:RadTreeViewItem>
                </telerik:RadTreeView>

            </telerik:RadOutlookBarItem>
            <telerik:RadOutlookBarItem Header="Company Filing" FontWeight="Bold"
                                Icon="../Images/Folder32.png"
                                SmallIcon="../Images/Folder32.png"
                                Tag="Company Filing" >

                <telerik:RadTreeView x:Name="CompanyFiling_TreeView" IsLineEnabled="True">
                    <telerik:RadTreeViewItem Header="CompanyFiling">

                    </telerik:RadTreeViewItem>
                </telerik:RadTreeView>
            </telerik:RadOutlookBarItem>
        </telerik:RadOutlookBar>

The {Binding Path=Items} is having all the values that I want and all the hierarchy.
in my code behind
 this.Browsers_TreeView.ItemsSource = MyNewListItems; (All the items).

Why I cannot populate the children of my hierarchy ?
Just to remind you that the same code is running for the accordion and the treeview inside the accordion.
Any ideas ?
thank you



2 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav
Telerik team
answered on 09 Aug 2010, 09:20 AM
Hello Zacharias Karasavvas,

I am sorry for the delayed reply.

The Telerik TreeView does not work with a toolkit HierarchicalDataTemplate, we use our own:

<telerik:HierarchicalDataTemplate/>

This is because we do not want to create a dependency on a toolkit assembly and we can support more features like ItemTemplateSelectors and ItemContainerStyleSelectors.

Do come back to us if you need more help.

Greetings,
Miroslav
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
0
Zacharias Karasavvas
Top achievements
Rank 1
answered on 10 Aug 2010, 07:36 AM
Hi ,
It worked .
Thank you
Tags
TreeView
Asked by
Zacharias Karasavvas
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Zacharias Karasavvas
Top achievements
Rank 1
Share this question
or