Repository navigation
ItemsStackPanel wasn't propagating correctly measure/arrange phases after invalidation - #484
Merged
Merged
Conversation
Member
Author
|
@davidjohnoliver Your input on this PR would be important. |
carldebilly
force-pushed
the
dev/cdb/bugs/itemsstackpanel-measure
branch
from
January 8, 2019 20:13
55bba0a to
bdc9454
Compare
to let measure & arrange phase propagate through children controls. This hack won't allow items to change their size, but that's better than before.
when the physical of the image is already known from a previous measure.
carldebilly
force-pushed
the
dev/cdb/bugs/itemsstackpanel-measure
branch
from
January 9, 2019 15:03
bdc9454 to
7a276ef
Compare
jeromelaban
approved these changes
Jan 9, 2019
Contributor
Agreed, it's a hack. :p |
kazo0
pushed a commit
to kazo0/uno
that referenced
this pull request
Mar 6, 2026
…lockStyles Dev/math/add text block styles
MartinZikmund
added a commit
that referenced
this pull request
May 28, 2026
MenuFlyout.Items and CommandBarFlyout.PrimaryCommands/SecondaryCommands host their items in logical-only collections — they're not visual descendants of Popup.Child until the presenter's template materialises during the upcoming layout pass. The previous fix (cdead2e) propagated the popup's theme to Child but NotifyThemeChanged only walks visual descendants, so the items kept the {ThemeResource} brushes they resolved against the application's global active theme at XAML parse time. The first frame then rendered with the wrong-theme brush, producing the visible first-open flash described in kahua-private #480 (light text on light background before the async corrective theme walk converged). After NotifyThemeChanged on Child, walk AssociatedFlyout's logical-only item collections and call NotifyThemeChanged on each. This re-resolves their {ThemeResource} bindings against the popup's theme before the first measure / render. Covers MenuFlyout (Items) and CommandBarFlyout (PrimaryCommands + SecondaryCommands), which also covers TextCommandBarFlyout — the TextBox edit context menu (Cut/Copy/Paste) where the user originally reported the flash. NotifyThemeChanged honours each item's own RequestedTheme override and short-circuits on no-op, so it is safe for already-correct items. Tests: add a flash-detection test to Given_MenuFlyout and Given_CommandBarFlyout that registers a PropertyChangedCallback on the item's Foreground and snapshots the value at every lifecycle checkpoint; asserts the brush is already the Light sentinel at the synchronous return of ShowAt (when the popup is in the tree and the first render is about to happen) and never the Dark sentinel at any user-visible checkpoint. Refine #480 / #484 repro comments in Given_ListViewBase and Given_ToolTip to explain how the same single XAML test runs on Uno (app-theme pinned to Dark via ThemeHelper.UseApplicationDarkTheme) vs native WinUI (Light-host baseline, since the app-theme pin is not available there).
MartinZikmund
added a commit
that referenced
this pull request
Jun 1, 2026
MenuFlyout.Items and CommandBarFlyout.PrimaryCommands/SecondaryCommands host their items in logical-only collections — they're not visual descendants of Popup.Child until the presenter's template materialises during the upcoming layout pass. The previous fix (cdead2e) propagated the popup's theme to Child but NotifyThemeChanged only walks visual descendants, so the items kept the {ThemeResource} brushes they resolved against the application's global active theme at XAML parse time. The first frame then rendered with the wrong-theme brush, producing the visible first-open flash described in kahua-private #480 (light text on light background before the async corrective theme walk converged). After NotifyThemeChanged on Child, walk AssociatedFlyout's logical-only item collections and call NotifyThemeChanged on each. This re-resolves their {ThemeResource} bindings against the popup's theme before the first measure / render. Covers MenuFlyout (Items) and CommandBarFlyout (PrimaryCommands + SecondaryCommands), which also covers TextCommandBarFlyout — the TextBox edit context menu (Cut/Copy/Paste) where the user originally reported the flash. NotifyThemeChanged honours each item's own RequestedTheme override and short-circuits on no-op, so it is safe for already-correct items. Tests: add a flash-detection test to Given_MenuFlyout and Given_CommandBarFlyout that registers a PropertyChangedCallback on the item's Foreground and snapshots the value at every lifecycle checkpoint; asserts the brush is already the Light sentinel at the synchronous return of ShowAt (when the popup is in the tree and the first render is about to happen) and never the Dark sentinel at any user-visible checkpoint. Refine #480 / #484 repro comments in Given_ListViewBase and Given_ToolTip to explain how the same single XAML test runs on Uno (app-theme pinned to Dark via ThemeHelper.UseApplicationDarkTheme) vs native WinUI (Light-host baseline, since the app-theme pin is not available there).
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.
Bugfix
Controls calling
.InvalidateMeasure()or.InvalidateArrange()when hosted in a virtualized list view (ItemsControl using aItemsStackPanel) were not remeasured nor rearranged.What is the current behavior?
The
Measurephase of anItemsStackPanelis not actually measuring its children. The method isused to calculate the virtualization and check if more items are required. Only newly added items
are getting measured (and arranged).
This faulty behavior is preventing images from stretching correctly. Since
their stretch values are calculated once the image is loaded (because we
need to know the physical dimension of the image), an
InvalidateMeasurewere issued on the
loadedevent. Hosting an image in a virtualized list werepreventing correct stretching of images, because the
Arrangemethod werenever called after the invalidation.
What is the new behavior?
New behaviors are added in this PR:
Measure, If the size is changed, the list is cleared and recreated.THIS IS OBVIOUSLY A HACK.
Measure, If the size DID NOT changed, the children items are simply remeasured.Arrange(when an item is added to the list), the calculatedRectis persisted.Arrange, all children items are being rearranged with the same size.PR Checklist
Please check if your PR fulfills the following requirements:
Internal Issue (If applicable):