Skip to content

feat(listview): Port ListViewItemPresenter and GridViewItemPresenter chrome - #25389

Merged
MartinZikmund merged 128 commits into
masterfrom
dev/mazi/listviewitempresenter
Nov 18, 2026
Merged

MartinZikmund merged 128 commits into
masterfrom
dev/mazi/listviewitempresenter

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #1444, closes #19707, closes #17231

PR Type:

✨ Feature

What changed? 🚀

ListView/GridView items on Skia used to render their chrome through the ListViewItemExpanded / GridViewItemExpanded templates: a full tree of Grids, Rectangles, Borders and VisualStates per container, which differed visually from WinUI and cost a lot per item. This PR is a 1:1 port of the WinUI 2.5.1 ListViewItemPresenter / GridViewItemPresenter chrome, and the default Fluent ListViewItem style now uses it, matching WinUI's template.

Targets 7.1. This is not a 7.0 change, so the notes moved out of the 7.0 migration guide into controls/ListViewBase.md. GridView uses the presenter by default too: the implicit GridViewItem style is BasedOn="{StaticResource DefaultGridViewItemStyle}" as in WinUI, and the Uno-only Fluent GridViewItemExpanded is removed. This absorbs #25925.

Depends on #25921. The ContentPresenter measure-time OnApplyTemplate commit was split out there at review request. It stays here until #25921 merges, then drops out on rebase.

  • Hidden base types: ListViewBaseItemPresenter, ListViewBaseItem and ListViewBaseItemTemplateSettings, as in WinUI.
  • Presenter properties: all ListViewItemPresenter / GridViewItemPresenter properties, including the rounded-chrome flag.
  • Item state machine: the ListViewBaseItem visual state machine and its wiring into ListViewBase interaction state (pointer over, pressed, selection, focus, drag and reorder).
  • Chrome core: state tables, child element management, measure and arrange, and the rendering layers.
  • Chrome animations: the animation command queue, ThemeGeneratorHelper, reorder and drag animations, and the selection-indicator animation.
  • Supporting changes:
    • template child hooks on ContentPresenter
    • internal TransitionTarget
    • theme-generated timelines start synchronously
    • CSizeUtil zero clamping
    • unsigned flag shifts in the DP generator for 32 bools
  • Resources: the Fluent ListViewItem/GridViewItem resources are resynced with WinUI.
  • Samples: the samples and the sample browser use the Fluent chrome.
  • WinUI sync: checked against microsoft-ui-xaml winui3/main as of 2026-11-13. The one chrome change since the port, Fix selection indicator lifetime across popup reconnection microsoft/microsoft-ui-xaml#12402 (a selected item whose indicator was dropped gets it back on measure or on a pointer-over/pressed selected state), is ported. The other upstream deltas don't apply here: the ListViewBaseItem::OnPointerReleased change needs AutomaticDragHelper, which isn't ported, and the ListViewBase telemetry and selection-focus changes belong with the ListView port that follows this PR.
  • Fixes found while measuring:
    • lazy BorderVisual path rebuilds no longer defeat picture collapse (GridView scroll ~50 → ~106 fps)
    • implicit presenter content is bound during the first measure

Performance (SamplesApp harness, Win32 Skia, Release, this branch vs its merge-base on master, 3 rounds, null-copy noise check)

ListView master this PR Δ
Elements per container 20 10 −50%
Heap per container 339 KB 248 KB −27%
Realize 1000 items, first frame 17.5 ms 14.9 ms −15%
Wheel scroll, process CPU 2456 ms 2016 ms −18%
Multi-select toggle, alloc per op 1.30 MB 0.83 MB −36%
Hover 0.31 ms 0.19 ms −40%

Single selection now runs WinUI's selection-indicator animation (~170 ms), which is a visible behavior change and not a regression.

GridView. The presenter element carries 41 {ThemeResource} and 9 {TemplateBinding} attributes per container. On GridViewItem that replaces only 5 template elements, so GridView got slower. This PR now reuses the chrome's hover and selection borders. The rest is fixed by general mechanism PRs, each of which also helps other controls:

The GridView default no longer waits for these PRs; they still improve it as they merge. GridView with all of them stacked, vs master (3 rounds, null-copy check):

GridView master stacked note
Realize 1000, settled 565 ms 584 ms +3%
Realize 100, settled 49.7 ms 40.8 ms better
Realize, first frame 263 ms ~470 ms not comparable: master's first frame has no item content (0/20 vs 20/20 containers measured)
Hover, sync 15.5 ms 12.3 ms better
Hover, settle 35 ms 45 ms 2 frames instead of 1: the Win32 pipeline renders before the layout tick when the border is added
Single select, alloc/op 19.0 KB 16.1 KB better
Multi-select, alloc/op 1.54 MB 1.67 MB see below
Multi-select, sync 3.9 ms 7.2 ms see below
Step scroll (multiple), CPU/frame 3.7 ms 4.7 ms see below

Why the multiple-selection rows can't match master. Master's GridViewItem default template has an empty MultiSelectEnabled state, so master shows no check boxes in multiple selection mode. This PR draws WinUI's overlay check box on every item, which master never renders, lays out or updates on selection.

Not in this PR

These are parked on purpose:

Until #25923 wires CustomizeFocusRectangle, the non-rounded Overlay chrome keeps drawing its selection/pointer-over ring on a keyboard-focused item, so the state stays visible. In WinUI the focus visual draws that ring instead.

Known gap: When_UpdateLayout_In_DragDropping_Content_AllowDrop keeps master's scenario (AllowDrop on the item content) but is [Ignore]d. This PR's drag path now runs into #25754, a bug master already has.

PR Checklist ✅

Behavior changes in 7.1 (documented in controls/ListViewBase.md):

  • The default GridViewItem template changes too. The Fluent GridViewItemExpanded is removed, as WinUI has none, so {StaticResource GridViewItemExpanded} resolves to the older non-Fluent copy in Generic.xaml. GridViewItem defaults to AllowDrop="True", as in WinUI.
  • The default ListViewItem template changes. The keyed ListViewItemExpanded style still ships and can be set explicitly as ItemContainerStyle.
  • ListViewItemPresenter / GridViewItemPresenter must be the template root. <Grid><ListViewItemPresenter/></Grid> now throws during measure, as in WinUI.
  • Over the middle of an item with AllowDrop="True", the item marks DragOver handled, as in WinUI. Plain DragOver handlers on the list don't run there, and built-in reordering only happens over the item's edge zones.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NL1zD4nmcDjrcPhceNXFNm
https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
https://claude.ai/code/session_01TXMNtydz1T8BfF5rA6Ft9N

@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/code-generation Categorizes an issue or PR as relevant to code generation area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 76494c0

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 71980c8

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

@github-actions

Copy link
Copy Markdown
Contributor

Ran the sync generator — no drift detected, nothing to commit.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 21s —— View job


Review summary: ListViewItemPresenter / GridViewItemPresenter chrome port

Verdict: no blocking issues found in the parts I checked. This was a targeted scan, not a line-by-line review of the ~18k added lines.

Checked

  • No event Action / event Action<T>, .GetAwaiter().GetResult(), async void, #pragma warning disable or Assert.Inconclusive in the new ListViewBase* sources or the new Primitives runtime tests.
  • The only [Ignore] is in Given_GridViewItemPresenter.cs:354. It sits behind #if !HAS_INPUT_INJECTOR, and ScrollBar tests use the same pattern. That fits the runtime-tests rules.
  • Ported files carry // MUX Reference headers and #nullable enable.

Review-bot float-equality comments (ListViewBaseItemChrome.uno.cs, ListViewBaseItemPresenter.mux.cs:751)

  • I'd dismiss them. The CornerRadius != 0, bounds.Width == 0.0f and m_fromScale != 0.0 checks mirror the cited WinUI sources.
  • Zero in those checks means "unset" or "none", not the result of arithmetic. Adding Epsilon tolerances would diverge from WinUI and could misclassify very small radii. I'd resolve them as won't-fix.

Cross-cutting items for the author

  • Validation evidence. I did not build or run anything, so my assessment is by inspection only. The PR's perf numbers and runtime tests are the author's own claims. Per the repo's validation protocol, please post the /runtime-tests results (Skia Desktop) for the new Given_ListViewItemPresenter*, Given_GridViewItemPresenter* and Given_ListViewBaseItem classes.
  • Screenshot diffs. CI reports 2458 Windows and 118 Linux snapshot changes. That count is far larger than the ListView/GridView samples would explain. The Screenshots Compare Test Run checklist item is unchecked, so confirm the diff is expected, for example a shared-theme or rendering side effect, before merge.
  • Breaking changes. The checklist item "Contains NO breaking changes" is unchecked, which is consistent with the stated template and constructor changes. Confirm the PackageDiffIgnore.xml entries cover them.
  • Generated stubs. src/Uno.UI/Generated/... files were modified. This looks like sync-generator output, which is acceptable only if it came from the generator. The bot reported no drift after /apply-sync-gen.
  • Presenter-heavy PR size. This is 100 files, mostly ported code, so I'd suggest running /review-panel master..HEAD before merge for deeper lens-based coverage.

@MartinZikmund
MartinZikmund marked this pull request as draft October 14, 2026 05:42
@unoplatform unoplatform deleted a comment from nventive-devops Oct 14, 2026
@unoplatform unoplatform deleted a comment from nventive-devops Oct 14, 2026
@unoplatform unoplatform deleted a comment from nventive-devops Oct 14, 2026
@unoplatform unoplatform deleted a comment from unodevops Oct 14, 2026
MartinZikmund and others added 26 commits November 18, 2026 10:52
InvalidateRender now marks the layers dirty, as WinUI's NWSetContentDirty
does, and the next arrange rebuilds them once, or when the size changes.
ChangeVisualState reads the cached rounded-chrome value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
DragBackground, DragForeground, DragOpacity, FocusBorderBrush and
FocusSecondaryBorderBrush have no reader while the drag visual and focus
rectangle are parked. ListViewItem.TemplateSettings is live now that
DragItemsCount updates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
The implicit GridViewItem style is BasedOn DefaultGridViewItemStyle again,
as in WinUI, so default GridView items render through the ListViewItemPresenter
chrome and default to AllowDrop=True. The Fluent GridViewItemExpanded is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
The chrome ships in 7.1, so describe it with ListViewBase rather than
as a 7.0 migration step, now including GridView's default style.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtydz1T8BfF5rA6Ft9N
Ports microsoft-ui-xaml#12402: measure and the pointer-over/pressed
selected states recreate the indicator when the item is still selected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtydz1T8BfF5rA6Ft9N
- Rebuild the chrome layers on every presenter property change, like
  WinUI's NWSetContentDirty flag.
- Keep drawing the Overlay state ring on keyboard focus until the focus
  visual takes it through CustomizeFocusRectangle (#25923).
- Stroke focus rectangles with any brush, as WinUI's static_cast does.
- Treat AcrylicBrush like WinUI, and connect other composition brushes
  before checking their CompositionBrush.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtydz1T8BfF5rA6Ft9N
WinUI flyouts size and place themselves for the last input device. The
touch injected here stayed the last input on WinAppSDK, where the harness
can't inject a mouse move to restore it, so Verify_MenuBarItem_Bounds
failed later in the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtydz1T8BfF5rA6Ft9N
Both baselines are winui3/release/2.5.1, the tag every MUX Reference header
names; detection against 2.6.5 reports both areas up to date. The shared
ListViewBaseItem chrome lives in the ListViewItemPresenter area, so the two
areas share no files.

The LVI/GVI theme resources are verbatim copies of CommonStyles, so they are
mirrored. The seed script's theme lookup keys off the _Partial names
(ListViewItemPresenter_themeresources.xaml) and does not find them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
A container DragStarting handler that cancels, even after a deferral,
gets no DropCompleted, so the list kept its primary dragged container,
drag count and visual states. Clean up like WinUI's wasCanceled path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
A Style value set under a Local one went through the method call and
replaced the backing field, though the store kept Local as highest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
Clearing a presenter alias left its forwarded value on the
ContentPresenter property. Track the forwarded precedence and clear it
when the alias reverts, as WinUI's single-slot target replaces it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 16s —— View job


Review summary: ListViewItemPresenter / GridViewItemPresenter chrome port

Verdict: ship after fresh evidence. This is a summary pass only. I did not read the ~19k-line diff, build, or run anything. It rests on the PR description and the existing review threads, so it is not an inspection or runtime validation of the current head. I posted no inline comments because I found no new defect.

Closed in the threads (per the author's replies)

  • ForwardAlias alias clearing and the Style-over-Local overwrite: db8cfdf and e3e7ba3, with tests.
  • Deferred DragStarting cancel leaving drag state set: d2c31c9, with a test in f5946ae.
  • HoldingState ambiguity: now fully qualified. The Holding and FrameId input fixes are split into fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags #26561.
  • Chrome invalidation, null-composition-brush and AcrylicBrush, the Overlay focus ring, Brush-typed focus options and the test wording: 420fea9 and d97ddfa.
  • The float-equality bot threads are exact-zero sentinel checks that mirror cited WinUI sources. I did not check those citations against the WinUI source. Won't-fix looks reasonable.

Still worth confirming (not re-verified)

  • Hit testing in rounded corners. HitTest applies the rounded-corner test to the presenter's own bounds only. A hit-testable child filling a rounded presenter may still receive input in the clipped corners. A small runtime test would settle it.
  • SelectorItem batching. It calls ChangeVisualState directly instead of UpdateVisualState(true), so the suspended-state batching in container preparation may be bypassed.
  • Alias slot encoding. Each alias slot stores precedence in 3 bits (AliasSlotBits). A one-line assert or a test would confirm every DependencyPropertyValuePrecedences value fits in 0-7.

Before merge

  • Land fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags #26561 first, then drop its commits on rebase.
  • Post fresh Skia Desktop /runtime-tests results for the presenter, ListViewBaseItem, holding, drag-cancel and alias-clearing classes, plus the unit tests. The existing evidence predates the latest commits.
  • Check the Screenshots Compare Test Run diffs. Build 247275 reports 447 Linux and 481 Windows changed snapshots. Many listed names (Buttons, Border_CornerRadius_*, BasicAcrylicBrushTest2) are not ListView-related.
  • Squash the comment-only and in-branch fix: commits so they stay out of the changelog.
  • Run /review-panel master..HEAD for a lens-based pass over a change this large.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.1 PRs only. For issues, use the Release field. area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure area/code-generation Categorizes an issue or PR as relevant to code generation area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimal ListViewItemPresenter Support ListView style differs between Skia and WinUI Support for ListViewItemPresenter and GridViewItemPresenter

7 participants