Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 415
Luke Puplett Avatar asked Mar 09 '26 17:03

Luke Puplett


2 Answers

You missed the configuration of the scroll viewer like this:

<ListView
   ScrollViewer.HorizontalScrollBarVisibility="Auto"
   ScrollViewer.HorizontalScrollMode="Enabled"
   ScrollViewer.VerticalScrollMode="Disabled" 
   ... > ...
like image 148
Luke Puplett Avatar answered Mar 12 '26 14:03

Luke Puplett


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

like image 38
JuanluElGuerre Avatar answered Mar 12 '26 14:03

JuanluElGuerre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!