Skip to content

Add hierarchical rows, context menu and live data samples to TableView - #2283

Merged
Niels Laute (niels9001) merged 4 commits into
microsoft:mainfrom
Nitin-100:user/nitchaudhary/tableview-hierarchy-sample
Nov 7, 2026
Merged

Niels Laute (niels9001) merged 4 commits into
microsoft:mainfrom
Nitin-100:user/nitchaudhary/tableview-hierarchy-sample

Conversation

@Nitin-100

@Nitin-100 Nitin Chaudhary (Nitin-100) commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 " (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 Fix TableView NullReferenceException in trimmed (Store) builds #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 ", 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 Light theme, filtered
Dark, keyboard focus on a nested row Dark, no matches
Dark theme, focused nested row Dark theme, empty state

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)
Nitin Chaudhary and others added 2 commits October 29, 2026 13:26
Adds a "Showing hierarchical rows" example to the TableView page. A flat
folder/file collection becomes nested rows through
TableViewSource.ParentBy(Id, ParentId); the options panel filters by name
(matches keep their ancestors) and expands or collapses every row.

Requires a Windows App SDK experimental release that includes the
TableView hierarchy API (ParentBy, ExpandAllRows/CollapseAllRows).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Give the hierarchy sample's Name column a MinWidth so third-level names
aren't truncated by the row indent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Nitin-100
Nitin Chaudhary (Nitin-100) marked this pull request as ready for review October 29, 2026 09:34
- Adding context menus to cells, rows, and headers: a Name column
  CellContextFlyout, a row menu from an implicit TableViewRow style, one
  shared HeaderContextFlyout that reads its column from MenuFlyout.Target
  (hide/show columns), and TableView.ContextFlyout as the fallback.
- Updating rows from live data: a DispatcherTimer updates observable
  items, and TableViewSource.IsLiveShaping keeps the sort and filter
  current while the selection follows its item. Options pause updates,
  turn live shaping off, and filter by value. The timer stops on Unloaded.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Nitin-100 Nitin Chaudhary (Nitin-100) changed the title Add hierarchical rows sample to TableView Oct 29, 2026
@hiteshkrmsft

Copy link
Copy Markdown

we should have shaping option to choose the flat grouped, hierarchy and Grouped-Hierarchy for the LDU section to show it's real capability
image

@@ -0,0 +1,162 @@
--- header

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snippet here doesn't match the implementation. Similarly for HierarchyTable.txt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 917d4b9. The HierarchyTable, ContextMenuTable and LiveDataTable snippets now copy the page code as is. Only AutomationIds are left out. I also added a catalog test, SnippetMatchesThePageImplementation, that fails if these snippets stop matching the page.

- Live data: add a Shaping selector (Flat, Grouped by trend, Hierarchy,
  Grouped hierarchy). Items now have a parent and a Trend group key, so
  live shaping re-sorts within groups and sibling sets, moves rows between
  trend groups, and moves top-level rows with their nested rows.
- The live table's timer now starts and stops with the table's own
  Loaded/Unloaded handlers.
- HierarchyTable.txt, ContextMenuTable.txt and LiveDataTable.txt now show
  the page's code verbatim (AutomationIds omitted), including the item
  classes and Output text, instead of rewritten versions.
- Add SnippetMatchesThePageImplementation, which fails if those snippets
  drift from TableViewPage.xaml, TableViewPage.xaml.cs or the item classes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Nitin-100

Copy link
Copy Markdown
Contributor Author

Added a Shaping option to the live data example with Flat, Grouped by trend, Hierarchy and Grouped hierarchy. With live shaping on, rows re-sort inside their group or parent, move between trend groups as values change, and parent rows keep their child rows when they move. Fixed in 917d4b9.

@dipeshmsft Dipesh Kumar (dipeshmsft) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@niels9001

Copy link
Copy Markdown
Collaborator
@niels9001
Niels Laute (niels9001) enabled auto-merge (squash) November 7, 2026 14:55
@niels9001
Niels Laute (niels9001) merged commit 4442429 into microsoft:main Nov 7, 2026
1 of 2 checks passed
Niels Laute (niels9001) added a commit that referenced this pull request Nov 8, 2026
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
- Bump WinUI Gallery to `3.1.0.0` for the next release, keeping the
project/assembly version and both package manifests synchronized.
- Upgrade Windows App SDK from `2.5.4-experimental` to
`2.6.6-experimental`.
- Fix the existing TableView header-menu example to use public APIs.
Each column owns its header flyout, allowing the opening handler to
identify the requested column without referencing the unprojected
`TableViewColumnHeader` type.
- Update the copyable TableView snippet, catalog, and regression
assertions.
- Document Chart UI Automation support and add an Appium regression test
for its accessible name, help text, axes, series, and six data points.

The branch is rebased onto current remote `main`. The TableView
hierarchy, context-menu, and live-data examples already landed in #2283,
so this PR reuses those examples rather than adding duplicates.
Scrolling-overflow examples and tests are excluded entirely.

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Prepare WinUI Gallery 3.1 and exercise the experimental SDK capabilities
in the existing gallery samples. The upstream TableView header handler
does not compile against the public 2.6.6 metadata; this change removes
that dependency while preserving the column-specific hide/restore menu
behavior.

Release notes:
https://github.com/microsoft/WindowsAppSDK/releases/tag/v2.6.6-exp

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Windows, Debug x64, packaged local Gallery, before the version-only
follow-up:
- `dotnet run --project tools\CatalogExporter -- generate` — passed;
regenerated catalog committed. Existing unrelated snippet warnings
remain.
- `dotnet test tests\WinUIGallery.CatalogExporter.Tests --verbosity
quiet` — passed, 172 tests.
- `dotnet build WinUIGallery\WinUIGallery.csproj -p:Configuration=Debug
-p:Platform=x64 --no-restore --verbosity quiet` — passed; existing
nullable/signing-certificate warnings remain.
- `dotnet build tests\WinUIGallery.UITests\WinUIGallery.UITests.csproj
--verbosity quiet` — passed.
- Local `winapp ui` checks — hierarchy expansion/collapse/filtering and
live shaping/filter/update toggles exercised repeatedly; Chart axes,
series, and all six accessible data points verified.
- The Name header menu opened with the correct “Hide Name” command. Full
repeated header hide/restore checks and dark-theme verification were
blocked by foreground-input safeguards; these are not claimed as
passing.
- The new Appium test was compiled but not run through
Appium/WinAppDriver. A diagnostic app run exited normally without
reporting a crash.

Version-only follow-up:
- `dotnet msbuild WinUIGallery\WinUIGallery.csproj
-p:Configuration=Release -p:Platform=x64
-getProperty:Version,AssemblyVersion,AssemblyFileVersion` — passed; all
three evaluated properties are `3.1.0.0`.
- Parsed both package manifests and verified their identity versions are
`3.1.0.0` — passed.
- Full Release package builds and Store submission have not been run.

## Screenshots (if appropriate):
N/A — this PR upgrades the SDK, bumps the Gallery version, and corrects
existing menu wiring; it does not add new sample layouts.

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] 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: Copilot App <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

4 participants