I have a ListView and I've simply replaced the ItemsPanel template with a StackPanel that's in horizontal mode, like so:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
However the items don't extend beyond the right hand side of the screen and thus, there's effectively no scrolling in any direction.
I copied the code from a //build/ session, so what did I miss?
You missed the configuration of the scroll viewer like this:
<ListView
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollMode="Disabled"
... > ...
Here your are the solutions. No changes for ScrollViewer is required. Default values work:
1) Vertical Scroll:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid MaximumRowsOrColumns="2" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
2) Horizontal Scroll:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<<ItemsWrapGrid/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
Regards Juanlu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With