ListViewItem ListViewItem ListViewItem Class

Represents the container for an item in a ListView control.

Syntax

Declaration

public class ListViewItempublic class ListViewItemPublic Class ListViewItem
<ListViewItem .../>
-or-
<ListViewItem ...>
  content
</ListViewItem>

Inheritance Hierarchy

Inherited Members

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

Remarks

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

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

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 ListViewItem control.

Resource keyDescription
ListViewItemForegroundText color at rest
ListViewItemForegroundPointerOverText color on hover
ListViewItemForegroundPressedText color when pressed
ListViewItemBackgroundBackground color at rest
ListViewItemBackgroundPointerOverBackground color on hover
ListViewItemBackgroundPressedBackground color when pressed
ListViewItemBackgroundSelectedBackground color when selected
ListViewItemBackgroundSelectedPointerOverBackground color on hover and selected
ListViewItemBackgroundSelectedPressedBackground color when pressed and selected
ListViewItemFocusVisualPrimaryBrushFocus indicator color when focused
ListViewItemFocusVisualSecondaryBrushSecondary focus indicator color when focused
ListViewItemFocusBorderBrushBorder color when focused
ListViewItemFocusSecondaryBorderBrushSecondary border color when focused
ListViewItemCheckBrushCheck mark color on selected item
ListViewItemCheckBoxBrushCheckmark box color on selected item
ListViewItemDragBackgroundItem background color when being dragged
ListViewItemDragForegroundItem foreground color when being dragged
ListViewItemPlaceholderBackgroundBackground color of item placeholder
ListViewItemSelectionCheckMarkVisualEnabledBoolean that specifies whether checkmark visual is shown
ListViewItemCheckModeSpecifies 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 ListViewItem class.

Properties summary

Gets an object that provides calculated values that can be referenced as TemplateBinding sources when you're defining templates for a ListViewItem class.

Constructors

  • ListViewItem()
    ListViewItem()
    ListViewItem()
    ListViewItem()

    Initializes a new instance of the ListViewItem class.

    public ListViewItem()public ListViewItem()Public Function ListViewItem() As

Properties

  • TemplateSettings
    TemplateSettings
    TemplateSettings
    TemplateSettings

    Gets an object that provides calculated values that can be referenced as TemplateBinding sources when you're defining templates for a ListViewItem class.

    public ListViewItemTemplateSettings TemplateSettings { get; }public ListViewItemTemplateSettings TemplateSettings { get; }Public ReadOnly Property TemplateSettings As ListViewItemTemplateSettings

    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.WebHostHiddenAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.UI.Xaml.Controls.dll