GridView GridView GridView Class


Represents a control that displays data items in rows and columns.

public class GridView : ListViewBase, IGridViewpublic class GridView : ListViewBase, IGridViewPublic Class GridView Inherits ListViewBase Implements IGridView
<GridView .../>
<GridView ...>
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


Use a GridView to display a collection of data in rows and columns that can scroll vertically. To display a collection stacked vertically, use a ListView.

Grid view control

GridView is an ItemsControl, so it can contain a collection of items of any type. To populate the view, add items to the Items collection, or set the ItemsSource property to a data source.

By default, a data item is displayed in the GridView as the string representation of the data object it's bound to. To specify exactly how items in the GridView are displayed, you create a DataTemplate to define the layout of controls used to display an individual item. The controls in the layout can be bound to properties of a data object, or have content defined inline. You assign the DataTemplate to the ItemTemplate property of the GridView. For common templates you can use in your app, see Item templates for grid layouts.


If you populate the GridView by setting the ItemsSource property, the ItemTemplate is applied to every item. If you populate the Items collection directly, the ItemTemplate is applied only if the item is not a GridViewItem. See Examples for more info.

If you use the GridView to display large sets of data, see Optimize ListView and GridView for tips to maintain a smooth and responsive user experience.

By default, a user can select a single item in a GridView. You can set the SelectionMode property to a ListViewSelectionMode enumeration value to allow multi-selection or to disable selection. You can also change the GridView interaction mode to make items respond to a user click like a button instead of being selected.

This table shows the ways a user can interact with a GridView, and how you can respond to the interaction.

To enable this interaction:Use these settings:Handle this event:Use this property to get the selected item:
No interactionSelectionMode = None, IsItemClickEnabled = FalseN/AN/A
Single selectionSelectionMode = Single, IsItemClickEnabled = FalseSelectionChanged SelectedItem, SelectedIndex
Contiguous multi-selectionSelectionMode = Multiple, IsItemClickEnabled = FalseSelectionChanged SelectedItems
Non-contiguous multi-selectionSelectionMode = Extended, IsItemClickEnabled = FalseSelectionChanged SelectedItems
ClickSelectionMode = None, IsItemClickEnabled = TrueItemClick N/A


The PointerWheelChanged event does not bubble up from a GridView. This means that a control that has a GridView inside of it does not receive mouse wheel change messages if the pointer is over the GridView. For example, if you put a GridView inside of a ScrollViewer, you can't scroll the ScrollViewer with the mouse wheel when the pointer is over the GridView.


When you set the Padding property on a GridView control, the value for right padding is ignored; only the values for left, top, and bottom padding are applied.

GridView supports data virtualization to improve performance with large data sets. Random access virtualization is supported when the data source implements the appropriate interfaces, which vary depending on the programming language:

Windows 8 In Windows 8, when the data item in a selected GridViewItem is replaced, the SelectedIndex value is not cleared. In Windows 8.1, the SelectedIndex value is cleared.

GridView implements the ISemanticZoomInformation interface, so it can be used as a view in a SemanticZoom control. When it's used in a SemanticZoom control, always set the ScrollViewer.IsHorizontalScrollChainingEnabled attached property to false on the ScrollViewer that's in the GridView 's control template, like this: <GridView ScrollViewer.IsHorizontalScrollChainingEnabled="False">. These members have an effect only when the GridView is hosted in a SemanticZoom control: IsActiveView, IsZoomedInView, SemanticZoomOwner, CompleteViewChange, CompleteViewChangeFrom, CompleteViewChangeTo, InitializeViewChange, MakeVisible, StartViewChangeFrom, StartViewChangeTo.

The default template for GridView includes existing transition animations. Specifically, the default ItemContainerTransitions value already contains values for AddDeleteThemeTransition, ContentThemeTransition, ReorderThemeTransition and EntranceThemeTransition (with IsStaggeringEnabled="False"). If you are setting a new value for ItemContainerTransitions on GridView, consider reproducing these same theme animations as a starting point. If you are setting the property yourself, those defaults get overwritten unless you include them again in your definition.

Selection behavior and CollectionViewSource

List controls that derive from Selector have a default selection behavior that depends on what the items source is (the type that's used for ItemsSource ). If the items source is a CollectionViewSource instance, then the behavior in the selection control is that the selection will default to the current item. When the list is first displayed, the selection defaults to the first item as current item. If you don't want the first item to be selected in this case, set IsSynchronizedWithCurrentItem to false in the GridView.


Here, a GridView is bound to a grouped CollectionViewSource named cvsProjects. The appearance of individual items in each group is defined by the ItemTemplate. The ItemsPanel specifies how the groups are arranged in the GridView. The GroupStyle.Panel specifies how individual items are arranged within each group. The GroupStyle.ContainerStyle is used to add a border around each group, and set its minimum size and margins. The HidesIfEmpty property is set to true to hide any empty groups.

<GridView ItemsSource="{Binding Source={StaticResource cvsProjects}}" 
  Margin="0,120,0,0" MaxHeight="500" Grid.Column="1">
            <StackPanel Margin="20">
                <TextBlock Text="{Binding Name}" FontWeight="Bold" 
                           Style="{StaticResource BaseTextBlockStyle}"/>
                <TextBlock Text="{Binding DueDate}" TextWrapping="NoWrap" 
                           Style="{StaticResource BodyTextBlockStyle}" />
                <CheckBox Content="Complete" IsChecked="{Binding Complete}" 
            <ItemsWrapGrid MaximumRowsOrColumns="3"/>

        <GroupStyle HidesIfEmpty="True">
                    <Grid Background="LightGray" Margin="0">
                        <TextBlock Text='{Binding Name}' 
                                   Foreground="Black" Margin="30"
                                   Style="{StaticResource HeaderTextBlockStyle}"/>

                <Border Background="LightGray" Height="200" Width="200">
                    <TextBlock Text="{Binding}" 
                               FontSize="48" Foreground="Green"/>


GridView() GridView() GridView()

Initializes a new instance of the GridView class.

public GridView()public GridView()Public Sub New()

See Also