简体   繁体   中英

how to make uniformgrid vertically

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.

The WPF UniformGrid layout is horizontal only, eg:

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?

我参加聚会有点晚了 - 但对于其他任何寻找解决方案的人来说,以下是有效的。

<UniformGrid Columns="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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM