GridViewItem GridViewItem GridViewItem Class

Represents the container for an item in a GridView control.

Syntax

Declaration

public class GridViewItempublic class GridViewItemPublic Class GridViewItem
<GridViewItem .../>
-or-
<GridViewItem ...>
  content
</GridViewItem>

Inheritance Hierarchy

Inherited Members

Inherited properties

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Tag
Tag
Tag
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Inherited events

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Inherited methods

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Remarks

The GridViewItem class provides the container for items displayed in a GridView control. You populate the GridView by adding objects directly to its Items collection or by binding its ItemsSource property to a data source. When items are added to the GridView, a GridViewItem container is created automatically for each item in the collection.

You can specify the look of the GridViewItem by setting the GridView 's ItemContainerStyle property to a Style with a TargetType of GridViewItem.

Control style and template

You can modify the default Style and ControlTemplate to give the control a unique appearance. For information about modifying a control's style and template, see Styling controls. The default style, template, and resources that define the look of the control are included in the generic.xaml file. For design purposes, generic.xaml is available in the (Program Files)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP&lt;SDK version>\Generic folder from a Windows Software Development Kit (SDK) installation. Styles and resources from different versions of the SDK might have different values.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background and Foreground. For more info, see the Light-weight styling section of the Styling controls article.

This table shows the resources used by the GridViewItem control.

Resource keyDescription
GridViewItemForegroundText color at rest
GridViewItemForegroundPointerOverText color on hover
GridViewItemForegroundPressedText color when pressed
GridViewItemBackgroundBackground color at rest
GridViewItemBackgroundPointerOverBackground color on hover
GridViewItemBackgroundPressedBackground color when pressed
GridViewItemBackgroundSelectedBackground color when selected
GridViewItemBackgroundSelectedPointerOverBackground color on hover and selected
GridViewItemBackgroundSelectedPressedBackground color when pressed and selected
GridViewItemFocusVisualPrimaryBrushFocus indicator color when focused
GridViewItemFocusVisualSecondaryBrushSecondary focus indicator color when focused
GridViewItemFocusBorderBrushBorder color when focused
GridViewItemFocusSecondaryBorderBrushSecondary border color when focused
GridViewItemCheckBrushCheck mark color on selected item
GridViewItemCheckBoxBrushCheckmark box color on selected item
GridViewItemDragBackgroundItem background color when being dragged
GridViewItemDragForegroundItem foreground color when being dragged
GridViewItemPlaceholderBackgroundBackground color of item placeholder
GridViewItemSelectionCheckMarkVisualEnabledBoolean that specifies whether checkmark visual is shown
GridViewItemCheckModeSpecifies how checkmark is shown ("Overlay" or "Inline")

Windows 8.1 To assign a custom value based on the data item to the NameProperty attached property, you must bind to the item container's Content property. For example, assume you have a Customer data item that has a Name property and you want to use the Customer.Name property as the NameProperty value.

In Windows 8, the data item is set as the DataContext of the item container, so you can use a binding like this: AutomationProperties.Name="{Binding Name}".

In Windows 8.1, the item container's DataContext is not set. To bind the NameProperty value to the data item's Name property, use a binding like this: AutomationProperties.Name="{Binding Path=Content.Name,RelativeSource={RelativeSource Mode=Self}}".

Constructors summary

Initializes a new instance of the GridViewItem class.

Properties summary

Gets an object that provides calculated values that can be referenced as TemplateBinding sources when defining templates for a GridViewItem.

Constructors

  • GridViewItem()
    GridViewItem()
    GridViewItem()
    GridViewItem()

    Initializes a new instance of the GridViewItem class.

    public GridViewItem()public New()Public Sub New()public GridViewItem()

Properties

  • TemplateSettings
    TemplateSettings
    TemplateSettings
    TemplateSettings

    Gets an object that provides calculated values that can be referenced as TemplateBinding sources when defining templates for a GridViewItem.

    public GridViewItemTemplateSettings TemplateSettings { get; }public GridViewItemTemplateSettings TemplateSettings { get; }Public ReadOnly Property TemplateSettings As GridViewItemTemplateSettingspublic GridViewItemTemplateSettings TemplateSettings { get; }

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Controls.dll