How to display items in two columns in a ListView

I am looking for a ListView layout in a Windows 8.1 application so that its elements wrap (no more) two columns that read in order, like a newspaper, and scroll vertically, e.g.

1 4 2 5 3 

The closest I got:

 <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapGrid Orientation="Horizontal" MaximumRowsOrColumns="2" /> </ItemsPanelTemplate> </ListView.ItemsPanel> 

but since MaximumRowsAndColumns is interpreted as Orientation , the result

 1 2 3 4 5 

Switching Orientation to Vertical gives me

 1 2 3 4 5 

Will I need a custom panel for this? Another tactic is perhaps the gridview inside the scrollviewer, but it seems a bit hacked to me.

+6
source share
1 answer

You should use ItemsWrapGrid :

 <ListView.ItemsPanel> <ItemsPanelTemplate> <ItemsWrapGrid /> </ItemsPanelTemplate> </ListView.ItemsPanel> 

This will give you the result you want:

 1 4 2 5 3 
+1
source

Source: https://habr.com/ru/post/979750/


All Articles