WPF: HierarchicalDataTemplate ItemsPanel

Posted by Echilon on Stack Overflow See other posts from Stack Overflow or by Echilon
Published on 2010-04-08T13:30:34Z Indexed on 2010/04/08 13:33 UTC
Read the original article Hit count: 551

I have a TreeView which uses a custom ItemsPanel to show the first level of items in a StackPanel, but I need to show subitems in a StackPanel too. The problem is, the second level of items are shown in a WrapPanel, and as HierarchicalDataTemplate doesn't have an itemsPanel property I'm not sure how to do this. This is my xaml:

<TreeView x:Name="treGlobalCards">
    <TreeView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel IsItemsHost="True" Orientation="{Binding Orientation,RelativeSource={x:Static RelativeSource.TemplatedParent}}"
                        MaxWidth="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"/>
        </ItemsPanelTemplate>
    </TreeView.ItemsPanel>
    <TreeView.ItemTemplate>
    <HierarchicalDataTemplate x:Key="CardTypeTemplate" ItemsSource="{Binding Cards}">
        <TextBlock Text="{Binding Path=CardType}"/>
    </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
</TreeView>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about datatemplate