Skip to content

Add tableview sample - #2250

Merged
Niels Laute (niels9001) merged 8 commits into
mainfrom
user/dotmorten/tableview
Sep 30, 2026
Merged

Niels Laute (niels9001) merged 8 commits into
mainfrom
user/dotmorten/tableview

Conversation

@dotMorten

@dotMorten Morten Nielsen (dotMorten) commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds five capability-focused examples for the experimental native TableView, under Collections between PullToRefresh and TreeView:

  • Basic: sorting, single-row selection, resizing, and a toggle to freeze the first column while scrolling horizontally.
  • Filtering and grouping: one shared TableViewSource, with a retained filter when changing grouping, expand/collapse commands, and an empty-result template.
  • Custom cell templates: ID, avatar/two-line Item, themed Status badge, progress/numeric Value, and read-only Rating columns.
  • Editing and validation: editable cells, required-name validation, and a read-only option.
  • Advanced: density, grid-line choices, an explicit row-banding toggle, empty state, and 1,000 virtualized rows.

Adds introductory, copyable App.xaml setup above the examples, showing TabularControlsResources immediately after XamlControlsResources in the merged resource dictionaries. Reuses the gallery's SampleCodePresenter and its existing Copy button.

Realized and recycled rows receive an accessible summary that tracks edits. The page-specific Axe exception is limited to the experimental control's virtualized row/cell peers that can remain in the UIA tree without bounds after recycling.

Selected changes from Pranav Gupta (@pranav-gupta-msft)'s TableView alternatives (#2252 and #2253) have been cherry-picked at the sample level and adapted into this branch. This keeps one Collections page and avoids duplicate feature sections rather than applying the alternative commits wholesale. Thanks for the focused feature samples.

Uses the DataGrid control image and refreshes the generated sample catalog.

Motivation and Context

Showcase the Windows App SDK 2.5.4-experimental TableView by capability rather than business scenario, and consolidate the alternative sample approaches into #2250.

PR validation first failed ManifestUpToDateTests.CommittedManifest_MatchesFreshGeneration. The original icon/configuration update left the catalog stale; subsequently, CI's automatic merge combined TableView and main's InkCanvas addition but retained controlCount: 124 instead of 125. This branch synchronizes main and its current catalog exporter, then regenerates and commits the complete catalog without changing or bypassing the guard.

The next validation passed all 157 catalog tests but exposed the TableView row accessibility issue in the complete Axe run. The sample now supplies live row names; only the framework-level null-bounds rule is excluded for this page.

How Has This Been Tested?

Windows, x64, .NET SDK 10.0.401. $testOutput, $previewOutput, and $uiOutput below were separate temporary output directories; the packaged Debug output supplies the resources needed by the native tests.

Passed - catalog generation with the main-synchronized exporter (125 controls, 341 samples):

dotnet run --no-restore --project tools\CatalogExporter -- generate

Passed - the complete catalog test suite, 159 tests, including catalog freshness, copyable resource setup, row banding, and accessible-row wiring:

dotnet test tests\WinUIGallery.CatalogExporter.Tests\WinUIGallery.CatalogExporter.Tests.csproj --no-restore --nologo --verbosity minimal

Passed - final packaged Debug/x64 app build:

dotnet build WinUIGallery\WinUIGallery.csproj --no-restore -c Debug -p:Platform=x64 -p:BuildAllAppFlavors=false -p:AppxBundle=Never "-p:OutDir=$testOutput" --nologo --verbosity minimal

Passed - TableView model tests, 11 tests:

dotnet test tests\WinUIGallery.UnitTests\WinUIGallery.UnitTests.csproj --no-restore -c Debug -p:IsTestProject=true -p:Platform=x64 -p:BuildAllAppFlavors=false -p:BuildProjectReferences=false -p:AppxBundle=Never "-p:OutDir=$testOutput" --filter 'FullyQualifiedName~TableViewSampleItemTests' --nologo --verbosity minimal

Passed - UI-test project compilation:

dotnet build tests\WinUIGallery.UITests\WinUIGallery.UITests.csproj --no-restore -c Debug -p:Platform=x64 -p:BuildProjectReferences=false "-p:OutDir=$uiOutput" --nologo --verbosity minimal

Passed - unpackaged Debug/x64 preview build with the resource introduction and row-banding option:

dotnet build WinUIGallery\WinUIGallery.csproj --no-restore -c Debug-Unpackaged -p:Platform=x64 -p:PublishSingleFile=false -p:BuildAllAppFlavors=false -p:AppxBundle=Never "-p:OutDir=$previewOutput" --nologo --verbosity minimal

Live UI checks verified trimmed/category/name filtering, changing grouping without clearing the query, empty results and restoration, group commands, freezing/unfreezing ID during horizontal scrolling, all five custom-template columns rendering without clipping, and toggling row banding. Template-header sorting could not be conclusively exercised through background input; the fresh complete CI UI/Axe run is pending on the final commit.

Screenshots (if appropriate):

Original preview screenshots, before the capability-focused consolidation:

image image image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
Consolidate sorting, row selection, resizing, and frozen columns in the basic example. Replace business scenarios with neutral custom-column, editing, and presentation samples.

Move TableView between PullToRefresh and TreeView, regenerate the sample catalog, and add focused model and catalog regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@marcelwgn Marcel W. (marcelwgn) changed the title User/dotmorten/tableview Sep 30, 2026
Adapt selected capabilities from #2252 and #2253 into five focused examples, with combined filtering/grouping, richer cell templates, frozen columns in Basic, and advanced presentation options. Refresh the generated catalog, including the DataGrid icon, to fix PR validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Synchronize the current catalog exporter and correct the control count after combining the TableView and InkCanvas additions. Add copyable App.xaml resource setup above the TableView examples with regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Make alternating row backgrounds discoverable in the Advanced sample with an accessible toggle. Keep the displayed XAML synchronized and cover its initial state and option metadata in catalog tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bind an accessible summary to realized and recycled TableView rows, including updates after editing. Keep the Axe exception limited to the experimental control's virtualized null-bounds peer issue and add regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@niels9001
Niels Laute (niels9001) merged commit 535ce17 into main Sep 30, 2026
4 checks passed
@niels9001
Niels Laute (niels9001) deleted the user/dotmorten/tableview branch September 30, 2026 17:49
This was referenced Oct 6, 2026
Niels Laute (niels9001) added a commit that referenced this pull request Oct 7, 2026
> Replaces #2256, which was opened from a fork. Same commits, plus the
latest `main` merged in. @pranav-gupta-msft's review feedback (move
Chart to Media) is included.

## Description
Adds a **Chart** page (Media, experimental) for
`Microsoft.UI.Xaml.Controls.Charts`, which ships in Windows App SDK
2.5.4-experimental (WinUI 2.3.10-experimental). Credit to @dotMorten:
this builds on his `user/dotmorten/charts` commit ("Add charting
samples"), rebased onto current `main`. His commit is preserved as the
first commit.

The page follows `AGENTS.md`: a copyable App.xaml setup snippet first,
then one idea per example.

| Example | Covers |
|---|---|
| Create a line chart with axes and a legend | `Samples`,
`Chart.Data`/`Axes`/`Series`, `CategoryAxis`, `LinearAxis`,
`LineSeries`, `ShowLegend`, `LegendTitle` |
| Create a bar chart and sort its categories | `BarSeries.Orientation`,
`CategoryAxis.SortKey`, `SortOrder` |
| Configure axes | `LinearAxis.Minimum`/`Maximum`/`Spacing`, `GridLines`
(None/Major/Minor), `Axis.IsVisible`, `ShowTickLabels`, `ShowTickMarks`,
`AxisLineBrush`, `TickBrush`, `GridLineMajorBrush`, `GridLineMinorBrush`
|
| Combine area, bar, and line series | Shared axes, legend entries,
`CartesianSeries.IsVisible`, `Fill`, `Stroke`, `StrokeDashStyle`,
`MarkerShape` |
| Customize lines, markers, and data labels | All `StrokeDashStyle` and
`MarkerShape` values, `StrokeThickness`, `ShowDataMarkers`,
`ShowDataLabels`, `DataLabelOverrides`, `DataMarkerOverrides` |
| Plot a time series | Chart built in code,
`DateTimeAxis.Minimum`/`Maximum`/`IntervalType`/`LabelFormat` |
| Update a series data source | `Samples.ItemsSource` bound to an
`ObservableCollection<double>` |

Other changes:
- **Known Chart control issue (worked around in the samples).**
`BarSeries.Orientation` defaults to `Horizontal`. A horizontal
`BarSeries` that shares a `CategoryAxis` X axis with an area or line
series leaves its chart blank. It also stops *other* charts on the same
page from drawing (only the legend title renders), even if the affected
chart is collapsed. The samples set `Orientation` explicitly on every
`BarSeries`, a test enforces it, and the bar example explains the
default. This needs a fix in the control; I can file it with the Charts
owners.
- **Theme-safe colors.** Chart properties reject `{ThemeResource}`
(`XamlParseException: Failed to assign to property`), and a nested
`SolidColorBrush Color="{ThemeResource …}"` doesn't follow a later theme
switch. The samples rely on the control's theme-aware defaults for text
and labels, and use fixed series colors that keep at least 3:1 contrast
in both themes. The previous black data label disappeared in dark theme.
- Option handlers apply changes only after the page loads. Initial
values are declared in markup, so the published catalog XAML matches
what the gallery renders.
- `ControlInfoData.json`: new `Chart.png` control image (it previously
used `Placeholder.png`), Learn API doc links, more search tags, and an
updated description.
- Listed under **Media**, next to InkCanvas / InkToolbar (per review).
- `catalog/windows-samples.json` regenerated.

## Motivation and Context
Chart is the third experimental control in 2.5.x, after TableView
(#2250) and InkCanvas/InkToolbar (#2245, #2247), and it has no gallery
page yet. This covers the whole public Charts API surface. The list was
taken from the 2.3.10-experimental winmd so no member is missed.

## How Has This Been Tested?
Windows 11 x64, Debug, .NET SDK 9.0.318 (app) and 10.0.401 (catalog
tools).

- `dotnet build WinUIGallery\WinUIGallery.csproj -c Debug
-p:Platform=x64 -p:BuildAllAppFlavors=false -p:AppxBundle=Never`: builds
with no new warnings.
- `dotnet run --project tools\CatalogExporter -- generate`, then
`check`: index up to date (126 controls, 349 samples). All seven Chart
samples publish well-formed XAML with no unresolved `$(…)` tokens.
- `dotnet test tests\WinUIGallery.CatalogExporter.Tests`: **166/166
pass**, including the new `ChartSamplesTests`:
  - The setup snippet is copyable and comes before the examples.
- `App.xaml` merges `XamlChartsResources` after `XamlControlsResources`.
- Example headers and snippets are checked, and the initial option
values are published.
- API coverage: a test fails if a sample stops demonstrating a Charts
member.
  - Every `BarSeries` sets `Orientation`.
  - No `{ThemeResource}` on chart properties.
- The last two guards were mutation-checked: each fails when the problem
is reintroduced.
- `dotnet format --verify-no-changes` is clean on the new page and test
files. `git diff --check` is clean.
- Ran the packaged app on the Chart page:
- **Axe.Windows** scan (same rules and global exclusions as
`AxeScanAllTests`): **0 errors**. No page-specific exclusion is needed.
- Drove every option through UI Automation, and the app stayed
responsive throughout: legend, orientation, sort key and order, all
grid-line modes, axis/tick toggles, series visibility, all 5 dash
styles, all 9 marker shapes, thickness, marker/label toggles, all
interval types and label formats, and live add/remove.
  - Checked all seven charts in light and dark theme.

## Screenshots
_Captured before the move to Media, so the navigation pane still shows
Chart under Collections._

<img width="975" height="813" alt="1-line-light"
src="https://github.com/user-attachments/assets/ac29ef29-2b71-45e9-b4d0-bbfe1a4468be"
/>
<img width="975" height="813"
alt="2-bar-horizontal-sorted-and-axes-minor"
src="https://github.com/user-attachments/assets/2fb29d05-3015-48a1-824d-a29ed4a5b496"
/>
<img width="975" height="813" alt="3-axes-and-combined-light"
src="https://github.com/user-attachments/assets/0c53588d-2aee-4b7a-bf4b-d754af264169"
/>
<img width="975" height="813" alt="4-series-hidden-and-dashdot-triangle"
src="https://github.com/user-attachments/assets/4823eb36-b326-42a1-849e-a9aff544036f"
/>
<img width="975" height="813" alt="5-lines-and-timeseries-day"
src="https://github.com/user-attachments/assets/249c20a4-060e-4471-9f7a-fd50d5a28ad1"
/>
<img width="975" height="813" alt="6-live-light"
src="https://github.com/user-attachments/assets/edd4a881-fb2c-4e22-a749-8a0d6fc618d2"
/>
<img width="975" height="813" alt="7-combined-dark"
src="https://github.com/user-attachments/assets/a8bafeda-603f-4a85-b452-d106e4a9a3b5"
/>
<img width="975" height="813" alt="8-line-bar-dark"
src="https://github.com/user-attachments/assets/333433ca-68c3-45c1-8a27-f8df5a01659c"
/>

## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

---------

Co-authored-by: Morten Nielsen <mn@iter.dk>
Co-authored-by: Nitin Chaudhary <nitchaudhary@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Niels Laute <nielslaute@microsoft.com>
Niels Laute (niels9001) pushed a commit that referenced this pull request Nov 7, 2026
#2283)

## Description

Adds three examples to the TableView page:

### 1. Showing hierarchical rows
- A flat folder/file collection (`TableViewHierarchyItem`, with `Id` and
`ParentId`) is shown as nested rows through
`TableViewSource.ParentBy(Id, ParentId)`. A null parent key makes a
top-level row.
- Options: a name filter (matches keep their ancestors, which stay
expanded while the filter is active), plus **Expand all rows** /
**Collapse all rows** (`ExpandAllRows` / `CollapseAllRows`).
- Keyboard: Right expands a row; Left collapses it or moves to the
parent; `*` expands the focused row's subtree.
- The Name column has `MinWidth="200"` so third-level names aren't
truncated by the indent.

### 2. Adding context menus to cells, rows, and headers
Shows how TableView chooses which menu to open:
- **Name cells:** a `CellContextFlyout` with "Copy name".
- **Other cells and rows:** the row's `ContextFlyout`, set through an
implicit `TableViewRow` style (Copy row / Move to next category /
Remove).
- **Column headers:** one `HeaderContextFlyout` shared by all columns.
Its `Opening` handler reads `MenuFlyout.Target`
(`TableViewColumnHeader.Column`) to offer "Hide <column>" (disabled on
the last visible column) and "Show all columns".
- **Everywhere else:** the table's own `ContextFlyout` ("Restore all
items") as the fallback.
- Menu items read their row from `DataContext`. Results go to the
example's Output.

### 3. Updating rows from live data
- A `DispatcherTimer` updates a few observable `TableViewLiveItem`
values every second, and the table is sorted by Value, descending.
- `TableViewSource.IsLiveShaping = true` re-applies the sort, filter,
grouping, and hierarchy on each `PropertyChanged`, so rows move as
values change and the selection stays with its row.
- A **Shaping** selector (Flat, Grouped by trend, Hierarchy, Grouped
hierarchy) shows live shaping on every projection: rows re-sort inside
their group or sibling set, move between Rising/Falling/Steady groups as
their change flips, and top-level rows keep their nested rows when they
move.
- Options: pause updates, turn live shaping off (cells still update but
rows stay in place), and filter to values of 50 or more (rows join and
leave as they cross 50).
- The timer starts and stops with the table's `Loaded` and `Unloaded`
events.

### Shared
- All new models are `partial`, per #2265, so trimmed Store builds keep
the CsWinRT vtable.
- `ControlInfoData.json`: adds `hierarchy`, `tree`, `context menu` and
`live data` tags, and updates the description.
`catalog/windows-samples.json` is regenerated.
- Tests:
  - The catalog test now expects 8 examples in order.
- New catalog tests cover the hierarchy, context menu, and live data
snippets.
- `SnippetMatchesThePageImplementation` fails if the three new snippets
stop matching `TableViewPage.xaml`, `TableViewPage.xaml.cs`, or the item
classes (only AutomationIds are left out of the snippets).
- New unit tests cover the hierarchy data (valid acyclic tree) and
`TableViewLiveItem` (tree shape, update, trend, clamping,
notifications).

## Motivation and Context

Follows #2250 (first set of TableView samples) by covering hierarchical
rows, context menus and live data updates, which TableView gained in
microsoft/microsoft-ui-xaml after #2250.

> [!IMPORTANT]
> **Blocked on the next Windows App SDK _experimental_ release.**
`ParentBy`, `ExpandAllRows`/`CollapseAllRows`,
`CellContextFlyout`/`HeaderContextFlyout`, and
`TableViewSource.IsLiveShaping` are not in `2.5.4-experimental`, so PR
validation fails to compile. The stable `2.6.4` release (27-Oct) doesn't
include them either, because TableView ships only in experimental
releases. All of these APIs are on the WinUI experimental release
branch. This PR deliberately does **not** change
`WindowsAppSdkPackageVersion`; the bump will be added when that release
ships.

## How Has This Been Tested?

Windows x64, .NET SDK 10.0.401, against a local build of
microsoft-ui-xaml `main` (466f4a35cb), referenced on top of
`2.5.4-experimental` with command-line-only overrides (no project files
in this PR change for that).

**Hierarchical rows**
- Initial tree, Expand all / Collapse all, and per-row expand via
`ExpandCollapsePattern` all work.
- Filtering: `jpg` keeps Pictures → Vacation → the two images, and `zzz`
shows the empty template.
- Keyboard: Right, `*` and Left (twice) behave as described.
- Checked visually in light and dark (screenshots below).

**Context menus** (opened through UI Automation `ShowContextMenu`, the
same path Narrator uses for Shift+F10)
- A Name cell opens the cell menu, and Copy name puts "Item 3" on the
clipboard.
- Category and Value cells open the row menu. Move to next category
changes Beta to Gamma, and Remove deletes the row.
- A header opens "Hide <that column>", and hiding works. On the last
visible column, Hide is disabled. Show all columns restores all three.
- The table itself opens the fallback menu, and Restore all items brings
back 5 rows.

**Live data**
- Starts sorted by Value, descending: the header reports "Sorted
descending".
- Rows stay sorted across updates, and the selected row stays selected
as it moves.
- Pause freezes the values.
- With live shaping off, the order drifts out of sort; turning it back
on re-sorts immediately.
- The ≥ 50 filter drops rows live as they fall below 50.
- Shaping: Grouped moves rows between trend groups live; Hierarchy keeps
parents and their children sorted; Grouped hierarchy moves a parent with
its children to its new trend group; switching back to Flat removes
groups and nesting. Filter in Hierarchy keeps matching rows with their
parent.
- Navigating away and back works, and updates resume.

**Builds and tests**
- **Trimmed publish:** `Release-Unpackaged` (`PublishTrimmed`, single
file). Hierarchy, all three menu levels, and live updates work with no
exception. The only trim warnings are pre-existing ones (`ItemPage`,
`WinRT.Runtime`).
- `dotnet test tests\WinUIGallery.CatalogExporter.Tests`: 172/172
passed. `CatalogExporter -- check`: index is up to date.
- `WinUIGallery.UnitTests` (TableView filter, through `vstest.console`):
20/20 passed.

## Screenshots (if appropriate):

Hierarchical rows. Screenshots of the context menu and live data
examples will be added with the package bump.

| Light, all rows expanded | Light, filter "jpg" |
| --- | --- |
| ![Light theme,
expanded](https://raw.githubusercontent.com/Nitin-100/WinUI-Gallery/b63393eefcc4fb8f11fef8fb233e729b1082e6e1/shot_light_expanded.png)
| ![Light theme,
filtered](https://raw.githubusercontent.com/Nitin-100/WinUI-Gallery/b63393eefcc4fb8f11fef8fb233e729b1082e6e1/shot_light_filter.png)
|

| Dark, keyboard focus on a nested row | Dark, no matches |
| --- | --- |
| ![Dark theme, focused nested
row](https://raw.githubusercontent.com/Nitin-100/WinUI-Gallery/b63393eefcc4fb8f11fef8fb233e729b1082e6e1/shot_dark_expanded.png)
| ![Dark theme, empty
state](https://raw.githubusercontent.com/Nitin-100/WinUI-Gallery/b63393eefcc4fb8f11fef8fb233e729b1082e6e1/shot_dark_empty.png)
|

## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

---------

Co-authored-by: Nitin Chaudhary <nitchaudhary@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants