Skip to content

fix: Bind implicit presenter content during measure (backport #25921) - #26569

Open
mergify[bot] wants to merge 6 commits into
release/stable/7.0from
mergify/bp/release/stable/7.0/pr-25921
Open

mergify[bot] wants to merge 6 commits into
release/stable/7.0from
mergify/bp/release/stable/7.0/pr-25921

Conversation

@mergify

@mergify mergify Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25920

PR Type:

🐞 Bugfix

What changed? 🚀

Split out of #25389 at reviewer request (Xiaoy312 / ajpinedam) so it can be reviewed and reverted on its own.

Previously, a ContentPresenter with no explicit Content/ContentTemplate bindings only hooked up its implicit bindings to the templated parent in OnApplyTemplate, run on Loaded. The first layout therefore rendered it empty (e.g. default ListViewItem items at 40px, 36 containers realized instead of 26).

Now ContentPresenter overrides ApplyTemplate(out bool addedVisuals) and runs OnApplyTemplate() once (guarded by _appliedTemplate) from measure, mirroring CContentPresenter::ApplyTemplate in WinUI. OnLoaded keeps its guarded call, so subclass OnApplyTemplate overrides still run exactly once.

Runtime tests added in Given_ContentPresenter:

  • When_Implicit_Content_Binding_Presented_On_First_Measure (fails before the fix, passes after)
  • When_Binding_DataContext_Set_After_First_Measure (explicit {Binding Foo} with DataContext set after first measure still shows and updates Foo)
  • When_OnApplyTemplate_Called_Once_Across_Measure_And_Load

Validated on Skia Desktop: the 3 new tests pass, and the full Given_ContentPresenter class passes (273/273).

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT


This is an automatic backport of pull request #25921 done by [Mergify](https://mergify.com).

MartinZikmund and others added 6 commits November 18, 2026 05:58
A ContentPresenter without explicit Content/ContentTemplate bindings only
picked up its templated parent's content on Loaded, after the first frame.
The default ListViewItem template (a bare ListViewItemPresenter) therefore
rendered its first frame with empty 40px items and realized 36 containers
instead of 26. WinUI sets these bindings in CContentPresenter::ApplyTemplate,
which runs from measure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
(cherry picked from commit 0213b64)
Run the implicit Content/ContentTemplate bindings from ApplyTemplate,
before the template expands, through an idempotent helper instead of
latching the overridable OnApplyTemplate into measure. A templated
parent assigned after the first measure is still picked up on Loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
(cherry picked from commit c310f2d)
Native WinUI CI showed CFrameworkElement::InvokeApplyTemplate calls
OnApplyTemplate during measure. Restore the once-only call next to the
default template bindings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
(cherry picked from commit 507a7c0)
@mergify

mergify Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

@unodevops

Copy link
Copy Markdown
Contributor

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

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 247243 found UI Test snapshots differences: skia-linux-screenshots: 246, skia-windows-screenshots: 278

Details
  • skia-linux-screenshots: 246 changed over 2496

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AutomationProperties_AutomationId.png-dark
    • Basics.png-dark
    • Basics.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • AnimatedBackVisualSourceSamplePage.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Buttons.png-dark
    • Accessibility_Showcase.png
  • skia-windows-screenshots: 278 changed over 2496

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CenteredGridinGridwithtwofixedsizechildren.png-dark
    • CenteredGridinGridwithtwofixedsizechildren.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedVisualsTestbedPage.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AnimatedBackVisualSourceSamplePage.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • ClipboardTests.png-dark
    • BenchmarkDotNet.png
    • CompositionNineGridBrush_Source_Changes.png-dark

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants