Luke Puplett
Luke Puplett

Reputation: 45135

Windows 8 - ListView using Horizontal items panel doesn't scroll

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?

Upvotes: 2

Views: 5328

Answers (2)

JuanluElGuerre
JuanluElGuerre

Reputation: 77

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

Upvotes: 1

Luke Puplett
Luke Puplett

Reputation: 45135

You missed the configuration of the scroll viewer like this:

<ListView
   ScrollViewer.HorizontalScrollBarVisibility="Auto"
   ScrollViewer.HorizontalScrollMode="Enabled"
   ScrollViewer.VerticalScrollMode="Disabled" 
   ... > ...

Upvotes: 11

Related Questions