how to make uniformgrid vertically
Asked Answered
O

3

18

I'm using UniformGrid and it's making the items display horizontally. Is there a way to make it display vertically?

<ListView.ItemsPanel>
    <ItemsPanelTemplate>
        <UniformGrid Columns="3" />
    </ItemsPanelTemplate>
</ListView.ItemsPanel>

Any help would be greatly appreciated.

Oldtime answered 19/12, 2012 at 1:33 Comment(1)
you mean <UniformGrid Rows="3" />.Dip
B
20

The WPF UniformGrid layout is horizontal only, e.g.:

1 2 3
4 5 6
7 8 9

Perhaps you could use a WrapPanel instead and just set the ItemHeight and ItemWidth to your desired grid size and set the Orientation to Orientation.Vertical.

Or you could create a derived UniformGrid to handle Orientation, there is a good example on MSDN.

This one will display:

1 4 7
2 5 8
3 6 9

Is this what you mean?

Brewhouse answered 19/12, 2012 at 2:8 Comment(1)
The first source code in the link working fine which do what you want, the updated source code doesn't, use the first one.Ot
E
8

I'm a bit late to the party - but for anyone else searching for a solution, the following works.

<UniformGrid Columns="1" />
Eruptive answered 2/10, 2017 at 9:28 Comment(1)
What if we want a free-form grid without Columns/Rows specified?Bemock
H
-1

I'm a bit latER to the party, but for posterity's sake:

I'm just starting out with xaml and came across this problem today. For simplicity's sake, I ended up wrapping single-column UniformGrids in a multi-column, single-row UniformGrid:

<UniformGrid Columns="3">
    <UniformGrid Columns="1">
        <!--multiple child elements-->
    </UniformGrid>
    <UniformGrid Columns="1">
        <!--multiple child elements-->
    </UniformGrid>
    <UniformGrid Columns="1">
        <!--multiple child elements-->
    </UniformGrid>
</UniformGrid>
Homerus answered 7/6, 2020 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.