ItemsWrapGrid ItemsWrapGrid ItemsWrapGrid Class

Definition

Positions child elements sequentially from left to right or top to bottom in an ItemsControl that shows multiple items. When elements extend beyond the container edge, elements are positioned in the next row or column. Supports pixel-based UI virtualization and grouped layouts.

public sealed class ItemsWrapGrid : Panel, IItemsWrapGrid, IItemsWrapGrid2public sealed class ItemsWrapGrid : Panel, IItemsWrapGrid, IItemsWrapGrid2Public NotInheritable Class ItemsWrapGrid Inherits Panel Implements IItemsWrapGrid, IItemsWrapGrid2
<ItemsWrapGrid .../>

Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Remarks

ItemsWrapGrid can be used only as the ItemsPanel of an ItemsControl that displays more than one item at a time. It can't be used with an ItemsControl that displays only one item at a time, such as a ComboBox or FlipView. ItemsWrapGrid is the default ItemsPanel for GridView.

In an ItemsWrapGrid, elements are arranged in rows or columns that automatically wrap to a new row or column when the elements reach the container edge. If the MaximumRowsOrColumns property is set, items wrap when the specified number of rows or columns is reached instead.

Orientation

You set the Orientation property to specify whether the grid adds its items in rows or columns before wrapping. The default is Orientation.Vertical.

Note

For Universal Windows Platform (UWP) app on Windows 10, the default GridView template sets the Orientation to Horizontal.

When the value is Vertical, the grid adds items in columns from top to bottom, then wraps from left to right. Columns of items scroll or pan horizontally.

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. Rows of items scroll or pan vertically.

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

Examples

<GridView>
    <GridView.ItemsPanel> 
        <ItemsPanelTemplate>
            <ItemsWrapGrid Orientation="Horizontal"/>  
        </ItemsPanelTemplate> 
    </GridView.ItemsPanel> 
</GridView> 

Constructors

ItemsWrapGrid() ItemsWrapGrid() ItemsWrapGrid()

Initializes a new instance of the ItemsWrapGrid class.

public ItemsWrapGrid()public ItemsWrapGrid()Public Sub New()
Attributes

Properties

AreStickyGroupHeadersEnabled AreStickyGroupHeadersEnabled AreStickyGroupHeadersEnabled

Gets or sets a value that specifies whether a group header moves with the group when the group is panned vertically.

public bool AreStickyGroupHeadersEnabled { get; set; }public bool AreStickyGroupHeadersEnabled { get; set; }Public ReadWrite Property AreStickyGroupHeadersEnabled As bool
Value
bool bool bool

true if the group header moves with the group when the group is panned vertically; otherwise, false. The default is true.

Attributes

Remarks

Group headers can be sticky only when the group is panned vertically and the GroupHeaderPlacement is Top. If the panel's Orientation is Horizontal or GroupHeaderPlacement is not Top, this property is ignored.

Examples

<GridView>
    <GridView.ItemsPanel> 
        <ItemsPanelTemplate>
            <ItemsWrapGrid AreStickyGroupHeadersEnabled="False" Orientation="Horizontal"/>  
        </ItemsPanelTemplate> 
    </GridView.ItemsPanel> 
</GridView> 

AreStickyGroupHeadersEnabledProperty AreStickyGroupHeadersEnabledProperty AreStickyGroupHeadersEnabledProperty

Identifies the AreStickyGroupHeadersEnabled dependency property.

public static DependencyProperty AreStickyGroupHeadersEnabledProperty { get; }public static DependencyProperty AreStickyGroupHeadersEnabledProperty { get; }Public Static ReadOnly Property AreStickyGroupHeadersEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the AreStickyGroupHeadersEnabled dependency property.

Attributes

CacheLength CacheLength CacheLength

Gets or sets the size of the buffers for items outside the viewport, in multiples of the viewport size.

public double CacheLength { get; set; }public double CacheLength { get; set; }Public ReadWrite Property CacheLength As double
ItemsWrapGrid CacheLength="double" />
Value
double double double

The size of the buffers for items outside the viewport, in multiples of the viewport size. The default is 4.0.

Attributes

Remarks

To improve scrolling performance, ItemsWrapGrid creates and caches item containers for items that are off-screen on both sides of the viewport. The CacheLength property specifies the size of the buffers for the off-screen items. You specify CacheLength in multiples of the current viewport size. For example, if the CacheLength is 4.0, 2 viewports worth of items are buffered on each side of the viewport.

You can set a smaller cache length to optimize startup time, or set a larger cache size to optimize scrolling performance. Item containers that are off-screen are created at a lower priority than those in the viewport.

CacheLengthProperty CacheLengthProperty CacheLengthProperty

Identifies the CacheLength dependency property.

public static DependencyProperty CacheLengthProperty { get; }public static DependencyProperty CacheLengthProperty { get; }Public Static ReadOnly Property CacheLengthProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the CacheLength dependency property.

Attributes

FirstCacheIndex FirstCacheIndex FirstCacheIndex

Gets the index in the data collection of the first item in the cache.

public int FirstCacheIndex { get; }public int FirstCacheIndex { get; }Public ReadOnly Property FirstCacheIndex As int
Value
int int int

The index in the data collection of the first item in the cache. The default is -1.

Attributes

Remarks

The index of the container for the very first item and the focused items are not reported if they are not in the cache.

FirstVisibleIndex FirstVisibleIndex FirstVisibleIndex

Gets the index in the data collection of the first item on the screen. Partially visible items are considered to be on screen.

public int FirstVisibleIndex { get; }public int FirstVisibleIndex { get; }Public ReadOnly Property FirstVisibleIndex As int
Value
int int int

The index in the data collection of the first item on the screen. The default is -1.

Attributes

GroupHeaderPlacement GroupHeaderPlacement GroupHeaderPlacement

Gets or sets a value that specifies where group headers are positioned in relation to the group.

public GroupHeaderPlacement GroupHeaderPlacement { get; set; }public GroupHeaderPlacement GroupHeaderPlacement { get; set; }Public ReadWrite Property GroupHeaderPlacement As GroupHeaderPlacement
ItemsWrapGrid GroupHeaderPlacement="groupHeaderPlacementMemberName" />
Value
GroupHeaderPlacement GroupHeaderPlacement GroupHeaderPlacement

An enumeration value that specifies where group headers are positioned in relation to the group. The default is Top.

Attributes

Remarks

Valid values are Top and Left.

GroupHeaderPlacementProperty GroupHeaderPlacementProperty GroupHeaderPlacementProperty

Identifies the GroupHeaderPlacement dependency property.

public static DependencyProperty GroupHeaderPlacementProperty { get; }public static DependencyProperty GroupHeaderPlacementProperty { get; }Public Static ReadOnly Property GroupHeaderPlacementProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the GroupHeaderPlacement dependency property.

Attributes

GroupPadding GroupPadding GroupPadding

Gets or sets the amount of space around a group.

public Thickness GroupPadding { get; set; }public Thickness GroupPadding { get; set; }Public ReadWrite Property GroupPadding As Thickness
Value
Thickness Thickness Thickness

The amount of space around a group as a Thickness value. Thickness is a structure that stores dimension values using pixel measures. The default is a uniform Thickness of 0.

Attributes

GroupPaddingProperty GroupPaddingProperty GroupPaddingProperty

Identifies the GroupPadding dependency property.

public static DependencyProperty GroupPaddingProperty { get; }public static DependencyProperty GroupPaddingProperty { get; }Public Static ReadOnly Property GroupPaddingProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the GroupPadding dependency property.

Attributes

ItemHeight ItemHeight ItemHeight

Gets or sets the height of the layout area for each item that is contained in an ItemsWrapGrid.

public double ItemHeight { get; set; }public double ItemHeight { get; set; }Public ReadWrite Property ItemHeight As double
<ItemsWrapGrid ItemHeight="double" />
Value
double double double

The height of the layout area for each item that is contained in an ItemsWrapGrid. The default is Double.NaN, which results in the "Auto" layout behavior.

Attributes

Remarks

"Auto" layout and Double.NaN

The default value of ItemHeight and ItemWidth is not 0, it is Double.NaN. ItemHeight and ItemWidth support the ability to be an unset "Auto" value. Because ItemHeight and ItemWidth are Double values, Double.NaN is used as a special value to represent this "Auto" behavior. The layout system interprets the "Auto" value to generally mean that the object should be sized to the available size in layout, instead of to a specific pixel value. If you want the "Auto" behavior for an object when it is used in layout, leave ItemHeight and ItemWidth unset at their Double.NaN default value. If you have previously set values and want to reenable the "Auto" behavior with run-time code, set to Double.NaN. In XAML such as templates, you can set attribute values using the string "Auto".

Note

Visual C++ component extensions (C++/CX) doesn't have a constant for NaN, it uses a value, which appears as "-1.#IND" followed by zeros.

ItemHeightProperty ItemHeightProperty ItemHeightProperty

Identifies the ItemHeight dependency property.

public static DependencyProperty ItemHeightProperty { get; }public static DependencyProperty ItemHeightProperty { get; }Public Static ReadOnly Property ItemHeightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ItemHeight dependency property.

Attributes

ItemWidth ItemWidth ItemWidth

Gets or sets the width of the layout area for each item that is contained in an ItemsWrapGrid.

public double ItemWidth { get; set; }public double ItemWidth { get; set; }Public ReadWrite Property ItemWidth As double
<ItemsWrapGrid ItemWidth="double" />
Value
double double double

The width of the layout area for each item that is contained in an ItemsWrapGrid. The default is Double.NaN, which results in the "Auto" layout behavior.

Attributes

Remarks

"Auto" layout and Double.NaN

The default value of ItemHeight and ItemWidth is not 0, it is Double.NaN. ItemHeight and ItemWidth support the ability to be an unset "Auto" value. Because ItemHeight and ItemWidth are Double values, Double.NaN is used as a special value to represent this "Auto" behavior. The layout system interprets the "Auto" value to generally mean that the object should be sized to the available size in layout, instead of to a specific pixel value. If you want the "Auto" behavior for an object when it is used in layout, leave ItemHeight and ItemWidth unset at their Double.NaN default value. If you have previously set values and want to reenable the "Auto" behavior with run-time code, set to Double.NaN. In XAML such as templates, you can set attribute values using the string "Auto".

Note

Visual C++ component extensions (C++/CX) doesn't have a constant for NaN, it uses a value, which appears as "-1.#IND" followed by zeros.

ItemWidthProperty ItemWidthProperty ItemWidthProperty

Identifies the ItemWidth dependency property.

public static DependencyProperty ItemWidthProperty { get; }public static DependencyProperty ItemWidthProperty { get; }Public Static ReadOnly Property ItemWidthProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ItemWidth dependency property.

Attributes

LastCacheIndex LastCacheIndex LastCacheIndex

Gets the index in the data collection of the last item in the cache.

public int LastCacheIndex { get; }public int LastCacheIndex { get; }Public ReadOnly Property LastCacheIndex As int
Value
int int int

The index in the data collection of the last item in the cache. The default is -1.

Attributes

LastVisibleIndex LastVisibleIndex LastVisibleIndex

Gets the index in the data collection of the last item on the screen. Partially visible items are considered to be on screen.

public int LastVisibleIndex { get; }public int LastVisibleIndex { get; }Public ReadOnly Property LastVisibleIndex As int
Value
int int int

The index in the data collection of the last item on the screen. The default is -1.

Attributes

MaximumRowsOrColumns MaximumRowsOrColumns MaximumRowsOrColumns

Gets or sets a value that influences the wrap point, also accounting for Orientation.

public int MaximumRowsOrColumns { get; set; }public int MaximumRowsOrColumns { get; set; }Public ReadWrite Property MaximumRowsOrColumns As int
<ItemsWrapGrid MaximumRowsOrColumns="int" />
Value
int int int

The maximum rows or columns that this ItemsWrapGrid should present before it introduces wrapping to the layout. The default is -1, which is a special value that indicates no maximum.

Attributes

MaximumRowsOrColumnsProperty MaximumRowsOrColumnsProperty MaximumRowsOrColumnsProperty

Identifies the MaximumRowsOrColumns dependency property.

public static DependencyProperty MaximumRowsOrColumnsProperty { get; }public static DependencyProperty MaximumRowsOrColumnsProperty { get; }Public Static ReadOnly Property MaximumRowsOrColumnsProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the MaximumRowsOrColumns dependency property.

Attributes

Orientation Orientation Orientation

Gets or sets the dimension by which child elements are stacked.

public Orientation Orientation { get; set; }public Orientation Orientation { get; set; }Public ReadWrite Property Orientation As Orientation
ItemsWrapGrid Orientation="orientationMemberName" />
Value
Orientation Orientation Orientation

One of the enumeration values that specifies the orientation of child elements. The default is Vertical.

Attributes

Remarks

Note

ItemsWrapGrid is the default ItemsPanel for GridView. For Universal Windows Platform (UWP) app on Windows 10, the default GridView template sets the Orientation to Horizontal.

OrientationProperty OrientationProperty OrientationProperty

Identifies the Orientation dependency property.

public static DependencyProperty OrientationProperty { get; }public static DependencyProperty OrientationProperty { get; }Public Static ReadOnly Property OrientationProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Orientation dependency property.

Attributes

ScrollingDirection ScrollingDirection ScrollingDirection

Gets a value that indicates whether items are panning forward or backward, or aren't panning.

public PanelScrollingDirection ScrollingDirection { get; }public PanelScrollingDirection ScrollingDirection { get; }Public ReadOnly Property ScrollingDirection As PanelScrollingDirection
Value
PanelScrollingDirection PanelScrollingDirection PanelScrollingDirection

An enumeration value that indicates whether the items are panning Forward or Backward, or None if the items are not panning.

Attributes