-api-id | -api-type |
---|---|
T:Microsoft.UI.Xaml.Controls.UniformGridLayout |
winrt class |
Positions elements sequentially from left to right or top to bottom in a wrapping layout.
This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).
Items are layed out in order from left-to-right when the Orientation is Horizontal
, and layed out top-to-bottom when the Orientation is Vertical
.
Every item in a UniformGridLayout is sized equally.
UniformGridLayout supports virtualization when attached to a host that supports virtualization.
Tip
For more info, design guidance, and code examples, see ItemsRepeater.
The WinUI 3 Gallery and WinUI 2 Gallery apps include interactive examples of most WinUI 3 and WinUI 2 controls, features, and functionality.
If installed already, open them by clicking the following links: WinUI 3 Gallery or WinUI 2 Gallery.
If they are not installed, you can download the WinUI 3 Gallery and the WinUI 2 Gallery from the Microsoft Store.
You can also get the source code for both from GitHub (use the main branch for WinUI 3 and the winui2 branch for WinUI 2).
The following example shows how to set the ItemsRepeater.Layout property to a UniformGridLayout.
<!--
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
-->
...
<muxc:ItemsRepeater ItemsSource="{x:Bind Items}"
ItemTemplate="{StaticResource MyTemplate}">
<muxc:ItemsRepeater.Layout>
<muxc:UniformGridLayout MinItemWidth="200"
MinColumnSpacing="28"
ItemsJustification="SpaceAround"/>
</muxc:ItemsRepeater.Layout>
</muxc:ItemsRepeater>
UniformGridLayoutItemsJustification, UniformGridLayoutItemsStretch, UniformGridLayout overview