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

HierarchicalDataTemplate's ItemTemplate getting ignored

1 Answer 57 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 02 Aug 2011, 06:19 PM
I'm trying to set up a TreeView that uses HierarchicalDataTemplates, and I can get the first level of objects to show, but the ItemTemplate for the first data template doesn't seem to be doing anything. I changed the binding of the 2nd data template to a collection that doesn't exist, thinking I would at least get some binding errors, but it looks like the item template is getting completely ignored. At first I thought it was because the collections in the object were using EntityCollections, so I changed to a custom object that uses IEnumerables, but I'm still getting the same result. Here is what I have so far:

<Telerik:HierarchicalDataTemplate x:Key="RuleCondition" ItemsSource="{Binding RuleConditions}" ItemTemplate="{StaticResource ValidationFunction}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Priority: " />
                <TextBlock Text="{Binding RuleCondition.Priority}" />
            </StackPanel>
        </Telerik:HierarchicalDataTemplate>
        <Telerik:HierarchicalDataTemplate x:Key="Rule" ItemsSource="{Binding}" ItemTemplate="{StaticResource RuleCondition}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Rule.Name}" />
                <TextBlock Text=" | Description: " />
                <TextBlock Text="{Binding Rule.Description}" />
            </StackPanel>
        </Telerik:HierarchicalDataTemplate>
 
<Telerik:RadTreeView x:Name="RuleTreeView" IsEditable="true" IsLineEnabled="True" Telerik:StyleManager.Theme="Summer"
                ItemTemplate="{StaticResource Rule}" ItemsSource="{Binding}" Margin="5">

and in the code behind I set the DataContext to my collection of objects. Is there anything that would cause the ItemTemplate to get ignored?

Thanks,

Jeremy

1 Answer, 1 is accepted

Sort by
0
Jeremy
Top achievements
Rank 1
answered on 02 Aug 2011, 07:18 PM
Ok scratch that, I had my item sources mixed up! I didn't realize the ItemsSource for the HierarchicalDataTemplates should be set with the collection for the next data template. 
Tags
TreeView
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Jeremy
Top achievements
Rank 1
Share this question
or