# Data Table
> A table filled from a list, with a filter, sortable columns, row selection and pages.
Source: https://native.shellui.dev/docs/components/data-display/data-table
## Installation
```bash
shellui-native add data-table
```
**Platforms:** MAUI · Avalonia. Also installs `icon`, `button`, `table`, `input`, `checkbox`.
## Usage
### Basic
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=data-table-basic)
`ItemsSource` takes any list, and an `ObservableCollection` refreshes the table as it changes. Each column names the item property it shows:
```csharp
public record Invoice(string Number, string Customer, string Status, DateTime Date, decimal Amount);
```
- **Filter.** Every word typed in the field must be in the text of some column.
- **Sort.** A sortable header cycles ascending, descending and unsorted. Numbers and dates sort by value.
- **Selection.** `ShowSelection` adds a checkbox column. The header checkbox selects every row that passes the filter, across pages. `SelectedItems` holds the items, and `SelectionChanged` passes them.
- **Pages.** Ten rows at a time, with Previous and Next. Change the count with `PageSize`, or turn pages off with `ShowPagination="False"`.
Cells show text only. For badges or buttons in cells, build the rows yourself with [Table](https://native.shellui.dev/docs/components/data-display/table.md).
### Columns
`Width` takes a Grid column width: `*`, `2*` or a fixed number. `Format` is a .NET format string such as `C` or `MMM d, yyyy`. After changing an item's values in place, call `Refresh()`.
### Trimming and NativeAOT
`Property` is read by name at run time. In an app published with trimming or NativeAOT, set `Value` in code instead, so the property isn't trimmed away:
```csharp
InvoiceTable.Columns[0].Value = item => ((Invoice)item).Number;
```
## MAUI and Avalonia
- On Avalonia, sortable headers are tab stops, pressed with Enter or Space, and keep focus after sorting.
- On Avalonia a click on a row's checkbox doesn't raise `RowTapped`.
## API
### DataTable
XAML children go to `Columns`.
| Property | Type | Default | Description |
|---|---|---|---|
| `ItemsSource` | `IEnumerable` (MAUI) · `IEnumerable?` (Avalonia) | `null` | The items to show, one row each. An `ObservableCollection` refreshes the table as it changes. |
| `ShowFilter` | `bool` | `true` | Shows the filter field above the table. |
| `FilterPlaceholder` | `string` | `"Filter..."` | Hint in the empty filter field. |
| `ShowPagination` | `bool` | `true` | Splits the rows into pages, with Previous and Next. |
| `PageSize` | `int` | `10` | Rows per page while `ShowPagination` is on. |
| `ShowSelection` | `bool` | `false` | Adds a checkbox column; the header checkbox selects every row that passes the filter. |
| `EmptyText` | `string` | `"No results."` | Shown when no row passes the filter. |
| `MinimumContentWidth` | `double` | `0` | Below this width the table scrolls sideways instead of squeezing its columns. 0 never scrolls. |
| Event | Arguments | Description |
|---|---|---|
| `SelectionChanged` | `IReadOnlyList