ListView
Multi-column data display with headers, grid lines, and row selection.
Overview
ListView extends Selector and renders tabular data with column headers,
grid lines, and row-based selection. Columns are defined via ListViewColumn objects
specifying Header, Width, and DisplayMemberBinding. The
header row is separated from data rows by a horizontal line using box-drawing characters. Column
separators use │, header lines use ─, and crossings use
┼. The selected row is highlighted with configurable colors.
Basic Example
<ListView SelectedIndex="0">
<ListView.Columns>
<ListViewColumn Header="Name" Width="20" />
<ListViewColumn Header="Size" Width="10" />
<ListViewColumn Header="Modified" Width="18" />
</ListView.Columns>
<ListViewItem Content="report.pdf 2.4 MB 2026-04-10" />
<ListViewItem Content="notes.txt 128 B 2026-04-09" />
<ListViewItem Content="image.png 1.1 MB 2026-04-08" />
</ListView>
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| SelectedBackground | Color | Blue | Background color of the selected row. |
| SelectedForeground | Color | White | Foreground color of the selected row. |
| HeaderBackground | Color | DarkGray | Background color of the column header row. |
| HeaderForeground | Color | White | Foreground color of the column header row. |
| ShowGridLines | bool | true | Whether to display column separators and header line using box-drawing characters. |
| Columns | IList<ListViewColumn> | empty | Collection of column definitions. |
| SelectedIndex | int | -1 | Zero-based index of the currently selected row. Inherited from Selector. |
| SelectedItem | object | null | The currently selected data item. Inherited from Selector. |
| ItemsSource | IEnumerable | null | Data source for generating rows. Inherited from ItemsControl. |
ListViewColumn Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Header | string | "" | Text displayed in the column header. |
| Width | int | 10 | Character width of the column. |
| DisplayMemberBinding | Binding | null | Binding path to the property on each data item to display in this column. |
Creating Items
Inline ListViewItem Elements
<ListView>
<ListView.Columns>
<ListViewColumn Header="Process" Width="20" />
<ListViewColumn Header="PID" Width="8" />
<ListViewColumn Header="CPU" Width="8" />
</ListView.Columns>
<ListViewItem Content="dotnet 1234 12%" />
<ListViewItem Content="node 5678 8%" />
<ListViewItem Content="chrome 9012 24%" />
</ListView>
ItemsSource Binding with Columns
<ListView ItemsSource="{Binding Processes}" SelectedIndex="0">
<ListView.Columns>
<ListViewColumn Header="Name" Width="20"
DisplayMemberBinding="{Binding Name}" />
<ListViewColumn Header="PID" Width="8"
DisplayMemberBinding="{Binding ProcessId}" />
<ListViewColumn Header="Memory" Width="12"
DisplayMemberBinding="{Binding MemoryUsage}" />
</ListView.Columns>
</ListView>
Examples
Without Grid Lines
<ListView ShowGridLines="False" SelectedIndex="0">
<ListView.Columns>
<ListViewColumn Header="File" Width="25" />
<ListViewColumn Header="Status" Width="12" />
</ListView.Columns>
<ListViewItem Content="Program.cs Modified" />
<ListViewItem Content="App.xaml Unchanged" />
<ListViewItem Content="README.md New" />
</ListView>
Custom Header Colors
<ListView SelectedIndex="1"
HeaderBackground="DarkBlue"
HeaderForeground="Yellow"
SelectedBackground="DarkGreen"
SelectedForeground="White">
<ListView.Columns>
<ListViewColumn Header="Server" Width="18" />
<ListViewColumn Header="Status" Width="10" />
<ListViewColumn Header="Uptime" Width="12" />
</ListView.Columns>
<ListViewItem Content="web-01 Online 14d 3h" />
<ListViewItem Content="web-02 Online 14d 3h" />
<ListViewItem Content="db-01 Offline 0d 0h" />
</ListView>
Wide Table Layout
<ListView SelectedIndex="0">
<ListView.Columns>
<ListViewColumn Header="ID" Width="6" />
<ListViewColumn Header="Title" Width="30" />
<ListViewColumn Header="Author" Width="15" />
<ListViewColumn Header="Date" Width="12" />
</ListView.Columns>
<ListViewItem Content="#1 Fix null reference Alice 2026-04-10" />
<ListViewItem Content="#2 Add TreeView control Bob 2026-04-11" />
<ListViewItem Content="#3 Update documentation Charlie 2026-04-12" />
</ListView>
Keyboard Shortcuts
| Key | Action |
|---|---|
| Up Arrow | Move selection to the previous row. |
| Down Arrow | Move selection to the next row. |
| Home | Move selection to the first row. |
| End | Move selection to the last row. |
| Page Up | Move selection up by one page of visible rows. |
| Page Down | Move selection down by one page of visible rows. |
Key Concepts
ListViewextendsSelector, inheritingSelectedIndex,SelectedItem, andSelectionChangedevent.- Columns are defined via
ListViewColumnobjects withHeader,Width, and optionalDisplayMemberBinding. - When
ShowGridLinesisTrue, columns are separated by│characters, header lines use─, and crossings use┼. - The header row renders with
HeaderBackgroundandHeaderForegroundcolors, visually distinct from data rows. - Row data can be provided inline with
<ListViewItem>elements or generated fromItemsSourcewithDisplayMemberBindingon each column. - Use
DisplayMemberBindingon columns to automatically extract property values from bound data objects.