HierarchicalDataTemplate's ItemTemplate getting ignored

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    5 posts
    Member since:
    Jun 2011

    Posted 02 Aug 2011 Link to this post

    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
  2. Jeremy
    Jeremy avatar
    5 posts
    Member since:
    Jun 2011

    Posted 02 Aug 2011 Link to this post

    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. 
  3. DevCraft banner
Back to Top