-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Controls.WrapGrid |
winrt class |
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.
<WrapGrid ...>
oneOrMoreUIElements
</WrapGrid>
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 1 | Item 4 | Item 7 |
Item 2 | Item 5 | Item 8 |
Item 3 | Item 6 | Item 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 1 | Item 2 | Item 3 |
Item 4 | Item 5 | Item 6 |
Item 7 | Item 8 | Item 9 |
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.
OrientedVirtualizingPanel, IScrollSnapPointsInfo, ItemsControl.ItemsPanel, ItemsPanelTemplate, Quickstart: Adding ListView and GridView controls