2

I'm kinda new at XAML and I'm trying to figure how to display the TreeView nodes horizontally instead of vertically, i.e

Header 1
  Item 1 Item 2 item 3
Header 2
  Item 4

Instead of

Header 1
  Item 1
  Item 2
  Item 3
Header 2
  Item 4   

It's not really as simple as it seems, I was able to get the headers to go horizontally though...

XAML Code below

<Grid >      
<TreeView ItemsSource="{Binding Children}">
    <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type local:ApplicationListViewModel}"
                                  ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Title}"/>
            </StackPanel>
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type local:ApplicationViewModel}" >                    
            <StackPanel Orientation="Horizontal">
                <ListView>                        
                    <Button>
                        <Image Source="{Binding Image}"/>
                    </Button>
                </ListView>
            </StackPanel>
        </DataTemplate>
    </TreeView.Resources>
</TreeView>        





If it helps to know what I'm trying to accomplish with my code, then basically I'm trying to organise applications in a series of categories. A container(like a list box) is generated for each application category.

The data structure I have is

Application Collection
   Application List (1-> Many)
      Application (1-> Many)
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
John
  • 1,286
  • 2
  • 14
  • 22
  • 1
    I posted [this answer](http://stackoverflow.com/a/42860839/3063273) to a very similar [question](http://stackoverflow.com/q/364083/3063273). It might be helpful to people – Matt Thomas Mar 17 '17 at 15:04

1 Answers1

2

There's a codeproject article that explains exactly how to do this... Hope it helps :)

kiwipom
  • 7,639
  • 37
  • 37
  • Yup that answers the question perfectly, thank you. I passed over that article initially cause I wouldn't have thought about using styles to do that. – John Dec 07 '09 at 23:52