XAML: Render list items from left to right and grow from top to bottom

  • To render items like this (fixed width, grows vertically, like a Word document):

Item 1    Item 2
Item 3    Item 4

 

  • Use this XAML code:

[xml]
<ListView Width="200">
<ListBoxItem>
<TextBlock>Item 1</TextBlock>
</ListBoxItem>
<ListBoxItem>
<TextBlock>Item 2</TextBlock>
</ListBoxItem>
<ListBoxItem>
<TextBlock>Item 3</TextBlock>
</ListBoxItem>
<ListBoxItem>
<TextBlock>Item 4</TextBlock>
</ListBoxItem>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
[/xml]