How to control number of items appearing in GridVi

2019-08-30 00:35发布

问题:

I create GridView app and in the itemspage after binding items with the grid, it appears with 4 rows and 5 columns, when I rotate ScrollViewer to Vertical.

It appears with only one column. How can I control the number of rows and columns?

回答1:

You can control it in many ways depending on your layout which you have not shared. If you want a fixed number - make sure the height/width of your GridView is the correct multiple of the number of columns/rows that you want displayed. For example for a default GridView if you want to have 3 rows you could so something like:

<GridView
    Height="700">
    <GridView.ItemContainerStyle>
        <Style
            TargetType="GridViewItem">
            <Setter
                Property="Height"
                Value="200" />
...