Repository navigation
fix: Bind implicit presenter content during measure (backport #25921) - #26569
Open
mergify[bot] wants to merge 6 commits into
Open
mergify[bot] wants to merge 6 commits into
mergify[bot] wants to merge 6 commits into
Conversation
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)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT (cherry picked from commit 91de77d)
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)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA (cherry picked from commit b569bd5)
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)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA (cherry picked from commit a178b13)
2 of 5 tasks
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
The build 247243 found UI Test snapshots differences: Details
|
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ContentPresenterwith no explicitContent/ContentTemplatebindings only hooked up its implicit bindings to the templated parent inOnApplyTemplate, run onLoaded. The first layout therefore rendered it empty (e.g. defaultListViewItemitems at 40px, 36 containers realized instead of 26).Now
ContentPresenteroverridesApplyTemplate(out bool addedVisuals)and runsOnApplyTemplate()once (guarded by_appliedTemplate) from measure, mirroringCContentPresenter::ApplyTemplatein WinUI.OnLoadedkeeps its guarded call, so subclassOnApplyTemplateoverrides 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_LoadValidated on Skia Desktop: the 3 new tests pass, and the full
Given_ContentPresenterclass passes (273/273).PR Checklist ✅
Screenshots Compare Test Runresults.🤖 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).