Search code examples
c#visual-studioxamlwindows-store-apps

Gridview vertical scrolling - Windows Store App


I am making a Windows Store App using C#. Is it possible to make the Gridview a vertical scrolling gridview instead of horizontal?


Solution

  • I suppose you're not developing for Windows 10 UWP yet, as there it's vertical by default.

    If you want a 'vertical scrolling GridView' with a single column, then use a ListView instead. If you want vertical scrolling with multiple columns, you can use following XAML:

    <GridView
        ...
        ScrollViewer.HorizontalScrollBarVisibility="Disabled"
        ScrollViewer.HorizontalScrollMode="Disabled"
        ScrollViewer.VerticalScrollBarVisibility="Auto"
        ScrollViewer.VerticalScrollMode="Auto">
    
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapGrid Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
    
    </GridView>
    

    What you change from the default behavior is disabling horizontal scrolling and enabling vertical scrolling. Next to that you're telling the WrapGrid (or whatever container you're choosing to use) to place the items horizontally adjecent to each other and wrap to a new line vertically.