Skip to content

Latest commit

 

History

History
71 lines (44 loc) · 4.19 KB

wrapgrid.md

File metadata and controls

71 lines (44 loc) · 4.19 KB
-api-id -api-type
T:Windows.UI.Xaml.Controls.WrapGrid
winrt class

Windows.UI.Xaml.Controls.WrapGrid

-description

Positions child elements sequentially from left to right or top to bottom. When elements extend beyond the container edge, elements are positioned in the next row or column. Can only be used to display items in an ItemsControl. See Remarks.

-xaml-syntax

<WrapGrid ...>
  oneOrMoreUIElements
</WrapGrid>

-remarks

Important

Starting in Windows 8.1, ItemsWrapGrid is used as the default ItemsPanel for GridView. If you modify the ItemsPanel, we recommend you use ItemsStackPanel or ItemsWrapGrid instead of VirtualizingStackPanel or WrapGrid.

WrapGrid can only be used to display items in an ItemsControl.

The content of a WrapGrid is virtualized. This can improve performance when you work with large data sets. For more info, see Optimize ListView and GridView.

In a WrapGrid, elements are arranged in rows or columns that automatically wrap to a new row or column when the MaximumRowsOrColumns value is reached. The Orientation property specifies whether the grid adds its items in rows or columns before wrapping.

When the value is Vertical, the grid adds items in columns from top to bottom, then wraps from left to right, like this:

Item 1Item 4Item 7
Item 2Item 5Item 8
Item 3Item 6Item 9

When the value is Horizontal, the grid adds items in rows from left to right, then wraps from top to bottom, like this:

Item 1Item 2Item 3
Item 4Item 5Item 6
Item 7Item 8Item 9

Windows 8 behavior

For Windows 8, items added to the items lists programmatically at run-time sometimes would start a new row in the internal grid representation, even if the item could have been added to an existing row based on the MaximumRowsOrColumns setting.

Starting with Windows 8.1, items added to items lists programmatically at run-time will fill rows in expected ways, starting a new row only when row-column limits are exceeded.

This behavior difference usually has no effect on the layout the user sees, because the items control that contains the WrapGrid is ultimately controlling the layout. But the difference can be detected if you are using coordinate-relative techniques to check the layout within the WrapGrid. For instance, you might see coordinate differences if you are calling TransformToVisual or VisualTreeHelper API, with the WrapGrid as the "relative-to" element.

If you migrate your app code from Windows 8 to Windows 8.1, and you're doing advanced layout verification with TransformToVisual or VisualTreeHelper within a WrapGrid you may want to account for this behavior change.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

-examples

-see-also

OrientedVirtualizingPanel, IScrollSnapPointsInfo, ItemsControl.ItemsPanel, ItemsPanelTemplate, Quickstart: Adding ListView and GridView controls